I am running build pipeline for my REST API. I have upgraded my version to .net6.0. Below is my error:
The current .NET SDK does not support targeting .NET 6.0. Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 6.0.
Below is a part of my yaml for api:
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
publishWebProjects: true
zipAfterPublish: true
arguments: '--output $(build.artifactstagingdirectory)/api'
Kindly help me and let me know in case of any more details:
This issue is resolved. I had to add new step in my yaml and tell it to use/set the target framework .net6.0.x
- task: UseDotNet#2
displayName: Use .NET 6.0
inputs:
packageType: 'sdk'
version: '6.0.x'
installationPath: $(Agent.ToolsDirectory)/dotnet
Adding the above step in my yaml resolved both the errors.
Thank You :)
Related
When we run dotnet build on a .net 4.8 app, we get an error message. I attempted to install the developer pack for 4.8. However, that fails and I think the reason it fails is that .NET 4.8 is already installed on the system. What's the right way to resolve this issue?
##[error]C:\Program Files\dotnet\sdk\6.0.300\Microsoft.Common.CurrentVersion.targets(1221,5): Error MSB3644: The reference assemblies for .NETFramework,Version=v4.0 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
Is it that we cannot use dotnet build for 4.8 apps? Do we need to use MSBuild instead?
It requires the build agent be windows based, e.g. vmImage: 'windows-2022'.
- task: VSBuild#1
displayName: 'Dotnet build'
inputs:
solution: '*.sln'
msbuildArgs: '/t:build /p:DeployOnBuild=true /p:OutputPath="$(Build.ArtifactStagingDirectory)"'
restoreNugetPackages: true
configuration: '$(buildConfiguration)'
The above assumes the solution file is located in the root of the source repository.
While restoreNugetPackages is optional I received package not found errors until enabling it.
I am having a weird issue when trying to publish my .NET Core 3.1 Web Api.
In my YAML file I have added this to publish my project:
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
projects: 'BITSolutions.InvoiceTool.Service\BITSolutions.InvoiceTool.Service.csproj'
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
outputDir: '$(Build.ArtifactStagingDirectory)'
Everytime I run my build pipeline using this task, the task is executing the following line:
"C:\Program Files\dotnet\dotnet.exe" publish D:\a\1\s\BITSolutions.InvoiceTool.Web\BITSolutions.InvoiceTool.Web.csproj --configuration Release --output D:\a\1\a\BITSolutions.InvoiceTool.Web
It is publishing my Blazor Server project instead of my Service web api project as I stated in the task.
Any idea why?
Thanks in advance!
Not really a Blazor issue, more DevOps/YAML question.
The DotNetCoreCLI#2 task has a publishWebProjects parameter which defaults to true if not specified.
See https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops
Add the line
publishWebProjects: false
to the task, that should fix it.
This question already has answers here:
Build .NET Core 3.0 on Azure Pipelines
(7 answers)
Closed 3 years ago.
I'm creating a Azure DevOps pipeline, and I have a requirement to use .NET Core 3.1.
From the documentation, I can't see any obvious reference to the version of .NET Core that will be used with the DotNetCoreCLI task, so I gave it a try -
- task: DotNetCoreCLI#2
name: Dotnet_Restore
inputs:
command: 'restore'
feedsToUse: 'select'
This failed with the error The current .NET SDK does not support targeting .NET Core 3.1., but interestingly the logs state -
Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x SDK/Runtime along with 2.2 & 2.1.
With this is mind, I again looked at the documentation and came across the requestedMajor|Minor|PatchVersion parameters, so I updated my task -
- task: DotNetCoreCLI#2
name: Dotnet_Restore
inputs:
command: 'restore'
feedsToUse: 'select'
requestedMajorVersion: '3'
requestedMinorVersion: '1'
Sadly this also failed, with the same 'Info' statement as above.
The UseDotNet task seems to be what I need here, with the description stating -
Use this task in a build or release pipeline 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.
To test, I added a new task to the beginning of my pipeline, requesting .NET Core version 3.1.101 -
- task: UseDotNet#2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 3.1.x
installationPath: $(Agent.ToolsDirectory)/dotnet
Important Note
If you use the DotNetCoreCLI task in more than one job, you have to include the UseDotNet task at the beginning of each of those jobs. This is mighty inconvinient and hopefully something that can be improved in the future.
On Azure DevOps, I want to configure the .NET Core CLI task so that it executes restore with runtime win-x86.
I tried this configuration:
- task: DotNetCoreCLI#2
displayName: 'Restore NuGet'
inputs:
command: 'restore'
projects: './src/MySolution.sln'
feedsToUse: 'config'
nugetConfigPath: './NuGet.config'
arguments: '--runtime win-x86'
...which I thought would add --runtime win-x86 to the executed command. However, the command that gets executed...
/usr/bin/dotnet restore /home/vsts/work/1/s/./src/MySolution.sln --configfile /home/vsts/work/1/Nuget/tempNuGet_158.config --verbosity Detailed
...is missing the runtime option.
On Azure DevOps, is is possible to execute the .NET Core CLI task so that it executes restore with runtime win-x86?
I first tried to determine if there was something wrong with the documentation of the .NET Core CLI task by creating this issue, but it was closed without any dialog, and I was essentially told to post my question on SO instead.
I don't know why, but it look like the version 2 of the task DotNetCoreCLI can't take another arguments in the restore command.
Switch the version to 1 - DotNetCoreCLI#1 and it will work:
I am trying to add Code Coverage results in an Azure DevOps build for a .NET Core project, but, trying two different approaches based on this guide on MSDN:
Currently, after building the solution, I have a dotnet step for test, collecting the Code Coverage and publishing those results. I also tryed disabling this check for publishg, and adding a command line step and a Publish Test Results.
Here the screenshot and yaml for the test step:
- task: DotNetCoreCLI#2
displayName: 'Test solution'
inputs:
command: test
projects: '**/*Test/*.csproj'
arguments: '--configuration $(buildConfiguration) --collect "Code coverage"'
workingDirectory: ChustaSoft.Common.UnitTest
And here the screenshots and yaml for the currently disabled steps:
- script: 'dotnet test ChustaSoft.Common.UnitTest --logger trx --collect "Code coverage"'
displayName: 'Command Line Script'
enabled: false
- task: PublishTestResults#2
displayName: 'Publish Test Results'
inputs:
testResultsFormat: VSTest
testResultsFiles: '**/*.trx'
enabled: false
With both approaches, I could see Test results, but not the Code Coverage, here is an screenshot of what I am able to see it:
Any idea? I am missing something? How can I see the Code Coverage when the build is finished?
Thank you a lot in advance,
PD: Project is multitarget: .NET Core 2.0, .NET Standard 2.0 and .NET 4.6.1, UnitTest project is a .NET Core MSTest project
EDIT: Added Test step output:
Try to run the tests with adding first
Visual Studio Test Platform Installer Task
then
Visual Studio Test -->>Test assemblies Task
Remove the Publish Test and the Command line Tasks.