Recently got chances to work on Azure DevOps for Desktop (UWP/WPF/Desktop Bridge/MSIX) , and often need to CI/CD .Net Core and .Net Standard. Most of them are related to SDK setup, NuGet version update, TargetPlatform settings, or Code Sign Certificate trust. This article is to give quick references on how to solve common CI issues for this scenario.
NETSDK1045: The current .NET SDK does not support targeting .NET Core 2.2. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.2.
It is possible project targeted .Net Core version is different from the Build Agent environment. The direct method is to install .Net Core SDK accordingly:
Then go to site: https://dotnet.microsoft.com/download/dotnet-core/2.2 to install .Net Core 2.2 SDK for the self-host build agent. The issue will be solved.
Alternatively, you can also add .Net Core SDK Install task into build pipeline yml file if it is can be downloaded properly through DevOps pipeline. Open azure-pipelines.yml, in the right pane, we can easily add a task:
Note: you need to add SDK accurate version number, refer to the version list:
https://dotnet.microsoft.com/download/dotnet-core/2.2
https://dotnet.microsoft.com/download/dotnet-core/3.0
If your project is WPF and is ported to .Net Core, the error can be this:
Error : Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.
MSB4236: The SDK ‘Microsoft.NET.Sdk.WindowsDesktop’ specified could not be found.
Use the above methods to add .Net Core SDK can fix them.
WMC0621: Cannot resolve ‘GenXbf.dll’ under path ‘C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x86\genxbf.dll’.
When project target platform doesn’t match the build agent environment, this error message can happens. To fixed it, change Min or Target Platform versions. I set this for my VS2019 + 19H3 agent environment and this issue got fixed:
NU1201: Project [xxxx] is not compatible with uap10.0.17134 (UAP,Version=v10.0.17134). Project [xxxx] supports: netstandard2.0 (.NETStandard,Version=v2.0)
When Azure DevOps builds one .Net Standard project (here it is WebRTC for UWP), I hit this error message:
NU1201: Project [xxxx] is not compatible with uap10.0.17134 (UAP,Version=v10.0.17134). Project [xxxx] supports: netstandard2.0 (.NETStandard,Version=v2.0)
This is because the default NuGetToolInstaller installed an old NuGet version 4.3.0
task: NuGetToolInstaller@0
The old NuGet version doesn’t support .Net Standard 2.0 with UWP. To solve this, we need to set the NuGet tool version to higher version. In my environment, I explicitly set it as 5.2.0 in azure-pipelines.yml:
And then this issue was fixed.
NOTE (2021-05-15): The agent got updated to 2.186.1, with Nugt 5.2.0 still hits NU1201. I manually set it to 5.9.1, now it works again.
APPX0102: A certificate with thumbprint ‘XXXXXXXXXX’ that is specified in the project cannot be found in the certificate store. Please specify a valid thumbprint in the project file.
You may face such a error when perform CI in Azure DevOps for UWP project due to some reasons:
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets(4432,5): Error APPX0102: A certificate with thumbprint ‘320245B47FCFxxxxx692C7A9A4729xxxxx6FE4’ that is specified in the project cannot be found in the certificate store. Please specify a valid thumbprint in the project file.
The key point is to install the PFX on the agent properly for signing UWP package. There are some ways to workaround this in Azure DevOps default agent through scripts. For me it is convenient to have one self-host build agent so that I can easily import this certificate:
Note: to have a self-host agent, go through:
https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops
DevOps for Desktop: How to use Self-Hosted agent for Win10 UWP Desktop Apps in Azure DevOps Pipeline
$pwd = ConvertTo-SecureString -String “yourpassword” -Force -AsPlainText
Export-PfxCertificate -cert “Cert:\CurrentUser\My\xxxxxxxxxx692C7A9Axxxxxxxx6FE4” -FilePath c:\temp_StoreKey.pfx -Password $pwd
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.