I\'m developing a mobile app and using MS App Center for CI. Yesterday the Unit Test project failed to build in App Center with the following error. I couldn\'t recreate the
I had this problem because I had a nuget source that was no longer existing. After removing the faulty nuget source I restored the project and everything worked.
I restored the project via commandline:
dotnet restore
You need to set the same publish and building runtimes
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeFrameworkVersion>2.1.0</RuntimeFrameworkVersion> --> fix publishing issues
<PlatformTarget>AnyCPU</PlatformTarget> --> fix publishing issues
</PropertyGroup>
<ItemGroup>
<PackageReference Update="Microsoft.NETCore.App" Version="2.1.0" /> --> fix building issues
<ProjectReference Include="..\PublicSonar.Monitor.Persistent.Json\PublicSonar.Monitor.Persistent.Json.csproj" />
</ItemGroup>
</Project>
Try Adding <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
to your <PropertyGroup>
tag. Example :
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
I am on Visual Studio 2019. I encountered this issue when I tried to publish my project as Self-contained for the second time.
What I did to get rid of this error was:
It seemed to be caused by some faulty cache that can be cleared by switching to a different deployment mode.