AndrΓ‘s TΓ³th‘s professional blog
banditoth.net

Hey there πŸ‘‹, I’m banditoth a .NET MAUI developer from Hungary.
I write about software development with .NET technologies.

You can find me on:
LinkedIn | Github | StackOverflow | X / Twitter | Threads

Tag: visual studio

  • .NET Error: “The current NET SDK does not support targeting NET 7.0.”

    This content has 2 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.
    The current NET SDK does not support targeting NET 7.0. Either target . NET 6.0 or lower, or use a version of the NET SDK that supports .NET 7.0.
    

    This error message is indicating that the version of the .NET SDK that you are currently using does not support targeting .NET 7.0. In order to resolve this error, you have three options:

    • Update your Visual Studio instance to the latest available.
    • Target .NET 6.0 or lower in your application by modifying the target framework in your project file (e.g. .csproj) to a version lower than 7.0, and then rebuild your application.
    • Use a version of the .NET SDK that supports .NET 7.0. You can check the version of the SDK you are currently using by running dotnet --version in a command prompt or terminal, and then update it to the latest version that supports .NET 7.0.
      • You can check the SDK version by running dotnet –list-sdks and you can update your SDK version by running dotnet update sdk
      • Once you have updated your SDK version, you should be able to build your application targeting .NET 7.0 without encountering this error.
  • Setup .NET MAUI project on macOS

    This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

    You may also be interested to know how Xamarin.Forms has grown and who will be its successor. I was interested too, so I took the time between the two holidays to test the .NET MAUI developed by Microsoft, so you’ll get a couple of articles about it. First, I’ll show you the installation and how I managed it under macOS.

    It’s possible that by the time you read this post, you’ll be able to create a MAUI project from UI, but it’s not currently an available feature for me. However, a lot of the tutorials were outdated because .NET 6 with VisualStudio2022 has been released, and xCode 13 is not in beta either, so you can skip some unnecessary installations.

    But what is definitely needed

    • macOS capable device,
    • Visual Studio 2022,
    • xCode 13.

    Get started on macOS

    First thing first, fire up your macOS terminal, because we will start working in that.

    If you havent installed Redth’s MAUI check tool yet, lets do this with the command

    dotnet tool install -g redth.net.maui.check
    

    Once it has been successfully installed, you will see the following output

    You can invoke the tool using the following command: maui-check
    Tool 'redth.net.maui.check' (version '0.10.0') was successfully installed.
    

    So it says, that you can invoke the maui-check command from now on, but it’s a lie, since some things of ZSH terminal, we need to manually fresh up the terminals internal things, otherwise the maui-check command will fail with “Unknown command”.

    export PATH=$HOME/.dotnet/tools:$PATH
    

    From now on, you can freely invoke the

    maui-check
    

    Which results you the following output:

          _   _   _____   _____     __  __      _      _   _   ___                  
         | \ | | | ____| |_   _|   |  \/  |    / \    | | | | |_ _|                 
         |  \| | |  _|     | |     | |\/| |   / _ \   | | | |  | |                  
      _  | |\  | | |___    | |     | |  | |  / ___ \  | |_| |  | |                  
     (_) |_| \_| |_____|   |_|     |_|  |_| /_/   \_\  \___/  |___|                 
                                                                                    
    πŸš‘ .NET MAUI Check v0.10.0.0 πŸ’‰
    ────────────────────────────────────────────────────────────────────────────────
    This tool will attempt to evaluate your .NET MAUI development environment.
    If problems are detected, this tool may offer the option to try and fix them for
    you, or suggest a way to fix them yourself.
    
    Thanks for choosing .NET MAUI!
    ────────────────────────────────────────────────────────────────────────────────
    ⏳ Synchronizing configuration... ok
    ⏳ Scheduling appointments... ok
    

    It can fix a lot of things for you automatically, watch the output carefully, it prompts that you want to fix the issues or not.

    To be honest, i don’t know this command will do the work any of the things above, but if you run this, after doing the things above, its also fine:

    sudo dotnet workload install maui
    

    Create a new MAUI project

    Lets find a suitable place for our new project, then give out the following command:

    dotnet new maui -n YourMauiProjectName
    

    From now on, you can leave the terminal, and start editing the project in your favourite IDE, example the VS2022

    Run your very first application

    Since the projects are cannot be set as run projects in Visual Studio 2022 yet, we need to run our apps from the command line with this command

    dotnet build YourMauiProjectName -t:Run -f net6.0-maccatalyst
    

    This will run your app with mac Catalyst compilation, but you can create Android and iOS versions also with this command

  • Code by rules: Make editorconfig to enforce code conventions and consistency

    This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

    You can add an EditorConfig file to your project or codebase to enforce consistent coding styles for everyone that works in the codebase. EditorConfig settings take precedence over global Visual Studio text editor settings. This means that you can tailor each codebase to use text editor settings that are specific to that project. You can still set your own personal editor preferences in the Visual Studio Options dialog box. Those settings apply whenever you’re working in a codebase without an .editorconfig file, or when the .editorconfig file doesn’t override a particular setting. An example of such a preference is indent styleβ€”tabs or spaces.

    EditorConfig settings are supported by numerous code editors and IDEs, including Visual Studio. It’s a portable component that travels with your code, and can enforce coding styles even outside of Visual Studio.

    When you add an EditorConfig file to your project in Visual Studio, new lines of code are formatted according to the EditorConfig settings.

    EditorConfig visual editor in Visual Studio for Windows

    More detailed information, and syntax can be found here:

    https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options

  • Visual Studio: Azure DevOps Git – The pull operation failed

    This content has 4 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

    When trying to sync or pull our repository from remote, it fails with the following error:

    The pull operation failed, see Output Window for details.
    

    In the output window, the error is the following:

    Cannot determine the organization name for this 'dev.azure.com' remote URL. Ensure the `credential.useHttpPath` configuration value is set, or set the organization name as the user in the remote URL '{org}@dev.azure.com'.
    

    Go to Visual Studio’s Tools, and then Options, search for ‘Git’ in the searchbar.

    Select the Git Global Settings option, and find the ‘Credential helper’ setting, and set it from ‘Unset’ to:

    GCM For Windows
    

    This should solve your problem.

  • Visual Studio for Mac : Delete all ‘bin’ and ‘obj’ with script

    Visual Studio for Mac : Delete all ‘bin’ and ‘obj’ with script

    This content has 4 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

    Open a terminal where your source codes are stored, and give out the following command:

    sudo find . -iname "bin" -o -iname "obj" | xargs rm -rf
    

    Type your superuser password when the terminal prompts it. This will clean up some hard disk space for you.