DevOps for .Net Core/.Net Standard: Common CI Issues Solving
Published Aug 15 2019 01:54 AM 11.7K Views
Microsoft

 

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.
  • 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.
  • WMC0621: Cannot resolve ‘GenXbf.dll’ under path ‘C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x86\genxbf.dll’.
  • NU1201: Project [xxxx] is not compatible with uap10.0.17134 (UAP,Version=v10.0.17134). Project [xxxx] supports: netstandard2.0 (.NETStandard,Version=v2.0)
  • 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.

 

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:

 

1.png

 

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:

 

2.png3.png

 

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.

 

4.png

 

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:

 

5.png

 

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)

 

6.png

 

This is because the default NuGetToolInstaller installed an old NuGet version 4.3.0

 

task: NuGetToolInstaller@0

 

7.png

 

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:

 

8.png

 

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

 

  1. Use a power shell script to export pfx from your dev box if necessary (for example, VS may just add the cert to Cert Store and pfx is not under your project):

$pwd = ConvertTo-SecureString -String “yourpassword” -Force -AsPlainText

 

Export-PfxCertificate -cert “Cert:\CurrentUser\My\xxxxxxxxxx692C7A9Axxxxxxxx6FE4” -FilePath c:\temp_StoreKey.pfx -Password $pwd

 

  1. On the self-host agent, open certmgr.msc, install the temp_StoreKey.pfx to current user/my path:
 

9.png

 

  1. Queue Build again, the issue will be resolved.

 

Thanks!

 

Co-Authors
Version history
Last update:
‎May 15 2021 03:12 AM
Updated by: