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

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?

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

Related

service fabric running .net 6.0 application

We are migrating our application from .NET 4.6.1 to .NET 6.0.
after deploying the migrated application, it is failing to find framework dlls. After logging into cluster VM looks like .NET 6.0 is not installed on machines. Do we have to have to separately install .NET 6 on cluster?
existing cluster is configured for auto fabric upgrade and current fabric version is 9.0.1028.9590
Thanks
You definitely don't need to install .NET frameworks on Service Fabric - this should be bundled as part of your Service Fabric application packages. We recently went through the exact process of upgrading our applications and I can also confirm that our cluster does not have any recent .NET frameworks installed.
How do you create your deployment packages? I suspect this may be the source of your problem...
For example, if using Azure DevOps, basically you need the following build tasks:
Use Net Core => to install 6.0.x SDK
Restore nuget packages
Build your .sln file via VS Studio build task
Build your .sfproj file via another VS Studio build task with parameters /t:Package /p:PackageLocation=$(build.artifactstagingdirectory)\applicationpackage
And publish artifact using source $(build.artifactstagingdirectory)
Finally, use the default powershell script Deploy-FabricApplication.ps1 that comes with default VS Studio to register and deploy your application to cluster.

Azure DevOps : Building Visual Studio Solution containing mixture of .Net 6 and .Net Framework projects

I am stuck on an issue building my solution containing .NET 6 project and .NET Framework (4.0 and 4.6.1) projects on Azure DevOps build pipeline (with dotnet build and msbuild task).
I cannot use windows-2019 as build agent coz of .NET 6 and unable to make work windows-2022 coz of .NET framework < 4.8
anyone come across this and know how you/they tackled this situation please?
Upgrading .NET Framework option is an expensive approach time-wise.
Any help appreciated.
Thanks
Azure DevOps : Building Visual Studio Solution containing mixture of .Net 6 and .Net Framework projects
Just as you know, the .NET Core SDK and .NET Framework supported by Windows 2019 are:
And the .NET Core SDK and .NET Framework supported by Windows 2022 areļ¼š
So, you could not use the hosted agent Windows 2019 or Windows 2022 to build your mixture projects.
As workaround, you could create your private agent to install the .NET 6 and .NET Framework (4.0 and 4.6.1) SDK on your local machine, if you do not want to upgrade .NET Framework:
Self-hosted Windows agents

Azure DevOps: What do I need to build .Net 6 solutions?

We have an on-premises Azure DevOps 2019 server, with build pipelines for numerous .Net 4.x solutions that our small team maintains using VS2019.
The team is about to upgrade to VS2022, and at some point I would like to migrate some solutions to .Net 6. Can DevOps 2019 build .Net 6 solutions, and if so what changes are needed to support this (such as presumably installing VS2022 on the server)?
Will those solutions' build pipelines require any changes or should they continue to work as-is? They don't contain anything too clever, with steps such as: NuGet restore, build solution, run unit tests, NuGet pack & push. (The build pipelines are managed via the web GUI, not YAML, if that makes a difference).
Some solutions will remain .Net 4.x, so the server will still need to support (build) these.
You should just need two things:
First you have to install the corresponding SDK for building the apps (see sdk download - Build apps - SDK) on your build-agents.
(Optional) Add or modify your set SDK Task in your pipelines (see use dotnet core task).
One more hint, you don't need to install a whole VS on the server. The Build-Tools are enough (VS2022 Buildtools preview).

AzurePipeline failing due to: The reference assemblies for .NETFramework,Version=v4.6.1 were not found

I have an Azure pipeline setup for my builds. I have been running into this issue recently and cannot figure out a way to fix this:
##[error]C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1220,5): Error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
About a week or so ago lots of our builds were failing, MS had changed something and we were getting this sort of thing:
[error]C:\Users\VssAdministrator\.nuget\packages\codegeneration.roslyn.buildtime\0.6.1\build\CodeGeneration.Roslyn.BuildTime.targets(73,5): Error CGR1001: CodeGeneration.Roslyn.Tool (dotnet-codegen) is not available, code generation won't run. Please check https://github.com/AArnott/CodeGeneration.Roslyn for usage instructions.
However was able to solve this by explicitily adding a task to include the netcore2.1 sdk
- task: UseDotNet#2
inputs:
packageType: 'sdk'
version: '2.x'
Now this issues is fixed we are now posed with the error complaining it cannot find .NET Framework 4.6.1.
Anyways any idea whats going on, this is driving me banannas - any advice or insight greatly appreciated.
The .Net framework version 4.6.1 has been deprecated by Azure DevOps Microsoft-hosted agent. For now, there are two kinds of Microsoft-hosted agents:
windows-2019 OR windows-latest: .Net framework version 4.7.2 and 4.8 preinstalled. This is documented here.
windows-2022: .Net framework version 4.8 preinstalled. This is documented here.
That is, you need to use self-hosted agent to use .Net framework 4.6.1 in the pipeline.
From Agent pool - Change Agent Specification from Window-Latest to Window-2019 ,It seems MS has done some changes in default agent

Failed to use .NET SDK agent in Azure DevOps Build Pipeline

I have a ASP.NET Core 2.1 and added a nuget package of Microsoft.WindowsAzure.Storage , But after pushing the code to repo, the build pipeline occurs package error while running the build agent and is it necessary to add any other agents in build pipeline other than BUILD, RESTORE, TEST and PUBLISH.
[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x SDK/Runtime along with 2.2 & 2.1. Unless you have locked down a SDK version for your project(s), 3.x SDK might be picked up which might have breaking behavior as compared to previous versions.
This is the error it shows while running the pipeline.
As the error info indicates, it's not recommended to call latest 3.x sdk to restore,build,test,publish your project that targets asp .net core 2.1.
Though in most of time the build can pass, but the Publish step(task) may encounter this issue:
To resolve the issue:
We should specify the .net core sdk version we want to use before running tasks like restore,build,test,publish...
We could add a use .net core sdk task before other .net core tasks like this to pick up the .net core 2.1.x related version to do the following tasks instead of using .net core 3.x sdk:
Classic UI:
Specify 2.1.x+Include Preview Versions will pick up the latest version of 2.1 sdk.
Yaml:
In case you're using yaml format instead of classic UI format to configure the pipeline, its yaml format looks similar to this:
steps:
- task: UseDotNet#2
displayName: 'Use .Net Core sdk 2.1.x'
inputs:
packageType: sdk
version: 2.1.x
installationPath: $(Agent.ToolsDirectory)/dotnet
includePreviewVersions: true
Hope it helps and feel free to correct me if I misunderstand anything:)
I encountered the same issue with version 2.1.505 and now I am using the following configuration for variables and installer step for .NET Core in my yaml pipeline while using version 3.1.101 and it fixed my issue.
variables:
buildConfiguration: 'Release'
dotnetSdkVersion: '3.1.101'
steps:
- task: DotNetCoreInstaller#0
displayName: 'Use .NET Core SDK $(dotnetSdkVersion)'
inputs:
version: '$(dotnetSdkVersion)'
The following steps worked for me:
Add a task before restore task named "Use .Net Core"
Specify intended sdk version ending with 'x'. For example 2.x
Check "Include Preview Versions" option
Add this line in .csproj, into PropertyGroup tag
<TargetLatestRuntimePatch>false</TargetLatestRuntimePatch>