question

BiedermannJonas-9566 avatar image
0 Votes"
BiedermannJonas-9566 asked BiedermannJonas-9566 answered

Build in Visual Studio runs fine, msbuild fails

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>




vs-msbuild
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, which version of Visual Studio are you using?
Please refer to: NETSDK1005 and NETSDK1047: Asset file is missing target and check if that actions work for you.


0 Votes 0 ·

1 Answer

BiedermannJonas-9566 avatar image
0 Votes"
BiedermannJonas-9566 answered

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"





5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.