I'm trying to publish my app with Azure DevOps. I have on the same repo 2 Azure functions (v2 and 3), 1 web application and 2 "libraries projects" (.net Framework 4). So it's my first time with DevOps and it's really hard...
I have a problem when building. I use a VSBuild task to build all the projects at the same time. Here my yaml :
- task: UseDotNet#2
displayName: 'Use .NET SDK 2.1'
inputs:
packageType: 'sdk'
version: '2.1.202' #I tried some others versions too
- task: VSBuild#1
inputs:
solution: 'project.sln'
Here the error :
##[error]C:\Users\VssAdministrator\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): Error : It was not possible to find any compatible framework version
And in the csproj of the project (Azure Function)
<TargetFramework>netstandard2.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
Has someone an idea to make this build work ?
To resolve this ##[error]C:\Users\VssAdministrator\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): Error : It was not possible to find any compatible framework version error:
Make sure your 1 web application and 2 libraries projects both have the same version of Microsoft.NET.Sdk.Functions 1.0.29.
References: https://github.com/Azure/azure-functions-vs-build-sdk/issues/199#issuecomment-665776934 , It was not possible to find any compatible framework version. The specified framework 'Microsoft.NETCore.App', version '2.2.0' was not found and https://github.com/dotnet/core/issues/3487
Related
After the latest .Net Maui update, my iOS app will longer build using the macos-12 image. Does anyone know how to specify an older version of .Net Maui using the CmdLine#2 Task? Here is what my current Task looks like.
- task: CmdLine#2
displayName: 'Install Maui'
inputs:
script: 'dotnet workload install maui'
The new version of .Net Maui seems to be looking for Xcode 14.1 and the iOS 16.1 SDK because it's using microsoft.net.sdk.ios version 16.1.1481.
I'm trying to figure out what version to use and this is getting ridiculous. You would think that I could specify one of these versions, but that's simply not the case. This is so frustrating and makes no sense!!!
https://github.com/dotnet/maui/releases
You would think that something like this would work.
- task: CmdLine#2
displayName: 'Install Maui'
inputs:
script: 'dotnet workload install --sdk-version 7.0.1xx maui'
https://maui.blob.core.windows.net/metadata/rollbacks/7.0.1xx.json
This seems to suggest that the version of Asp.net determines the .Net Maui version.
https://learn.microsoft.com/en-us/answers/questions/947953/how-do-i-get-net-maui-service-releases.html
Maui version will be determined by .net version.
AzureDevOps Pipleline force Task to install a certain version / old version of .Net Maui
To install a certain version of .net Maui in Azure Pipeline, you can use the Use dotnet v2 task to set the .net version of the pipeline. Then it will install a certain version of Maui.
Here is an example:
steps:
- task: UseDotNet#2
displayName: 'Use .NET Core sdk 7.0.100'
inputs:
version: 7.0.100
- script: 'dotnet workload install maui'
displayName: 'Command Line Script'
Here is how I was able to install an old version of .Net Maui.
I told the Pipeline to use Version 7.0.100 of Asp.net.
- task: UseDotNet#2
displayName: .NET Version
inputs:
packageType: 'sdk'
version: '7.0.100'
I told the Pipeline to use the 7.0.1xx Release version of .Net Maui.
https://github.com/dotnet/maui/tree/release/7.0.1xx
- task: CmdLine#2
displayName: 'Install Maui'
inputs:
script: 'dotnet workload install maui --from-rollback-file https://maui.blob.core.windows.net/metadata/rollbacks/7.0.1xx.json --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json --source https://api.nuget.org/v3/index.json'
I developed WebAPI project using .NET Core 3.1.0 and integration tests using XUnit.
I added the below task in Azure DevOps CI Pipeline (azure-pipelines.yaml) to run the integration tests project.
- task: DotNetCoreCLI#2
displayName: 'Run API integration tests - $(buildConfiguration)'
inputs:
command: 'test'
arguments: '--configuration $(buildConfiguration)'
publishTestResults: true
projects: '**/IntegrationTests/IntegrationTests.csproj'
I got the below error during pipeline execution. How to resolve this error?
##[error]Error: The process '/usr/bin/dotnet' failed with exit code 1
##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://learn.microsoft.com/en-us/dotnet/core/tools/ and https://learn.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
##[error]Dotnet command failed with non-zero exit code on the following projects : /home/vsts/work/1/s/src/IntegrationTests/IntegrationTests.csproj
I've had a smiller issue but with .netcore 2.2. The problem was that the test tries to build before the test starts restoring the packages for the test, thus fails before the test runs or builds. One thinge that help me overcome this problem was this FAQ:
Most dotnet commands, including build, publish, and test include an implicit restore step. This will fail against authenticated feeds, even if you ran a successful dotnet restore in an earlier step, because the earlier step will have cleaned up the credentials it used.
To fix this issue, add the --no-restore flag to the Arguments textbox.
I've also read that the DotNetCLI had some issues when it came to tests like this one here
So I ended up using a script to solve this and other issues related to package restore.
- script: dotnet test '**/IntegrationTests/IntegrationTests.csproj' --configuration $(buildConfiguration) --logger trx;LogFileName=C:\temp\results
displayName: 'Run API integration tests - $(buildConfiguration)'
I hope that will help you or anyone who has similar issues.
I've had exactly the same problem, with the difference that my solution consisted of .net5 apps as well as .netcore3.1 apps.
I was able to solve this problem by specifying the newer dotnet runtime in the azure pipeline:
- task: UseDotNet#2
inputs:
version: '5.0.x'
packageType: runtime
I have a project that builds using the following frameworks:
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0</TargetFrameworks>
This compiles just fine on my local machine, but when I push it to Azure, it fails.
When I have the following in my YAML file:
variables:
solution: '**/*.sln'
buildConfiguration: 'Release'
buildPlatform: 'Any CPU'
platform: x64
- task: DotNetCoreCLI#2
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration)'
Then I get:
##[error]C:\Program Files\dotnet\sdk\3.1.403\Microsoft.Common.CurrentVersion.targets(1177,5):
Error MSB3644: The reference assemblies for .NETFramework,Version=v5.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
And if I try
- task: VSBuild#1
displayName: 'Build all'
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
maximumCpuCount: true
I get:
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1177,5):
Error MSB3644: The reference assemblies for .NETFramework,Version=v5.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
The developer packs documentation refer only to the older .Net Framework, so I suspect this is irrelevant/outdated.
This works fine if I change .Net 5 for .Net Core 3.1, i.e. <TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
The reason your project doesn't build successfully is because the Microsoft-Hosted agent doesn't have the.NET 5.0 SDK installed.
You can download the.NET 5.0 SDK using Use.NET Core Task:
- task: UseDotNet#2
inputs:
packageType: 'sdk'
Version: '{version}'
includePreviewVersions: {true/false}
This task can download a specific version of the .Net SDK from the network and add it to the PATH.
In addition, since you are using multiple versions of .NET in your project, you can use this task to specify which version of.NET you will use in the following tasks.
In other words, this task has two functions:
Download a specific SDK version that is not installed.
Specify which SDK version will be used for the following tasks.
I think there is a problem with build agent machines.
If you use cloud azure devops you need to wait when they will update their build machines.
If you use on premise azure devops try to update build machines by yourself.
I can't solve an error from Nuget Restore in pipeline of Azure DevOps.
Starting: NuGet restore
==============================================================================
Task : NuGet
Description : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and
authenticated feeds like Azure Artifacts and MyGet. Uses NuGet.exe and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task.
Version : 2.161.0
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/package/nuget
==============================================================================
##[error]No neutral-language version resource found in the file
Finishing: NuGet restore
this is my NUGET Restore step in YAML:
steps:
- task: NuGetToolInstaller#1
displayName: 'Use NuGet 3.5.0'
inputs:
versionSpec: 3.5.0
- task: NuGetCommand#2
displayName: 'NuGet restore'
inputs:
restoreSolution: 'Projects/Wpf Helper.sln'
vstsFeed: '9d280068-ebce-4e32-9320-8e07068cc0e0'
I've read this topic and changed nuget version from 3.5.0 to 5.3.1, none of these version helps, same error : No neutral-language version resource found in the file.
How can I solve this problem?
I had planned to move my DevOps Pipeline to linux vm. Unfortunately, I faced with this problem. I am using Postsharp 6 on my .Net Core 2.2 project.
Build FAILED.
/home/vsts/.nuget/packages/postsharp/6.1.18/build/PostSharp.targets(148,5): error MSB4062: The "PostSharp.MSBuild.PostSharpValidateLanguageVersion" task could not be loaded from the assembly /home/vsts/.nuget/packages/postsharp/6.1.18/build//net471/PostSharp.MSBuild.v6.1.18.Release.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. [/home/vsts/work/1/s/Core.csproj]
/home/vsts/.nuget/packages/postsharp/6.1.18/build/PostSharp.targets(148,5): error MSB4062: Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [/home/vsts/work/1/s/Core.csproj]
0 Warning(s)
1 Error(s)
PostSharp doesn't work on Linux VM.
The only solution is using Windows Server on yaml. Even Selenium removed Postharp support.
trigger:
- master
pool:
vmImage: 'windows-2019'
variables:
buildConfiguration: 'Release'
steps:
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
You can look at the pictures to understand the steps better.
Update
PostSharp 6.3.5 preview version supports Linux and macOS builds.
Also, you can create a docker image too. I am using these images:
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build