'How can I specify the minor version of a .Net 6 target application to 6.0.1

I have a .Net 6 application that is deployed to a large number of desktops. Our IT infrastructure team installs a specific version of the .Net 6 (6.0.1)

When I compile this in Visual Studio or in a Azure DevOps pipeline the latest available .Net 6 version is taken. This is problematic because we don't want to keep on updating the .Net6 version on our many desktops

In the csproj file

<TargetFramework>net6.0-windows</TargetFramework>

Ideally I would like to specify something like

<TargetFramework>net6.0-windows;netcoreapp6.0.1</TargetFramework>

But this does not work. How can I specify that the target should be .Net 6.0.1 in Visual Studio or in the Build step in my Build Pipeline?



Solution 1:[1]

In Azure DevOps pipeline, the Use .NET Core task may help you. You can add this task before build.

Use this task to acquire a specific version of .NET Core from the Internet or the tools cache and add it to the PATH.

You can also use this task to change the version of .NET Core used in subsequent tasks like .NET Core cli task.

steps:
- task: UseDotNet@2
  displayName: 'Use .NET Core sdk'
  inputs:
    packageType: sdk
    version: 6.0.1
    installationPath: $(Agent.ToolsDirectory)/dotnet

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Oscar