Build in Visual Studio runs fine, msbuild fails

Biedermann, Jonas 21 Reputation points
2022-05-18T13:36:47.593+00:00

We need to build a msix package (wapproj) with our DevOps pipeline. We only want to build for platform x64 on windows for the time being. We have a bunch of projects with target framework netstandard2.1 projects and some with net5.0-windows10.0.17763.0.

When building with Visual Studio, we have no problems. But when building with msbuild (locally or on DevOps) we get the following error:

[error]C:\Program Files\dotnet\sdk\6.0.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5): Error NETSDK1047: Assets file 'D:\a\1\s\iv-core\IV.Math\obj\project.assets.json' doesn't have a target for 'netstandard2.1/win-x64'. Ensure that restore has run and that you have included 'netstandard2.1' in the TargetFrameworks for your project. You may also need to include 'win-x64' in your project's RuntimeIdentifiers.

Setting the runtime identifier in the .cproj file of the to all .netstandard projects lets the build pass, but that cannot be the solution since .netstandard dlls should work on all platforms. What are we missing?

Executable project file referenced by the wapproj:

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows10.0.17763.0</TargetFramework>
<Platform>x64</Platform>
<PlatformTarget>x64</PlatformTarget>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ninject" Version="3.3.4" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\iv-core\IV.UI.WPF\IV.UI.WPF.csproj" />
<ProjectReference Include="..\iv-core\IV.Update\IV.Update.csproj" />
</ItemGroup>

</Project>

One of the referenced csproj that throws the error:

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>

</Project>

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,995 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Biedermann, Jonas 21 Reputation points
    2022-05-19T09:25:59.013+00:00

    I found a solution for the problem. One can add a RuntimeIdentifier for the whole build as a msBuildArgument like so:

    msbuild -restore /property:Configuration=Debug;Platform=x64;RuntimeIdentifier="win-x64"

    0 comments No comments