5

We're creating a new Windows application with a WPF interface. For various reasons, we are attempting to make all of the supporting libraries run on net standard 2.0.

So the WPF project, Foo, references .NET Standard 2.0 projects from the same solution.

My problem is with getting the solution to build on the TeamCity build server.

msbuild gives an error when building the solution (works fine in Visual Studio 2017).

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(268,9): error MC1000: Unknown build error, 'Cannot resolve dependency to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.' [Src\Foo\Foo.csproj]

If I use nuget to add NetStandard.Library to the Foo project, then I get a different error from msbuild (still works fine in visual studio).

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(178,5): error : Your project.json doesn't have a runtimes section. You should add '"runtimes": { "win": { } }' to your project.json and then re-run NuGet restore. [Src\Foo\Foo.csproj]

There isn't a projects.json file.

It's running with 15.0 version of msbuild

External Program Failed: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MsBuild.exe (return code was 1)

2 Answers 2

1

Starting with a fresh build server solved the problem. I guess there were too many versions of msbuild and visual studio or SDKs or something on the old ones.

Sign up to request clarification or add additional context in comments.

Comments

0

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(268,9): error MC1000: Unknown build error, 'Cannot resolve dependency to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.' [Src\Foo\Foo.csproj]

The error message indicates you are using MSBuild for .NET Framework 4.0 to attempt to compile your assembly.

You should use dotnet msbuild to compile your .NET Standard 2.0 library and do note you need to have the .NET Core 2.0 SDK installed on the build machine.

dotnet msbuild /p:Configuration=Release

A simple way to install the .NET Core 2.0 SDK remotely on a CI server is to execute the dotnet-install script.

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(178,5): error : Your project.json doesn't have a runtimes section. You should add '"runtimes": { "win": { } }' to your project.json and then re-run NuGet restore. [Src\Foo\Foo.csproj]

This error indicates your build server has a preview version of the .NET Core SDK on your server that uses project.json format. You will need the .NET Core 2.0 SDK in order to build.

6 Comments

Thanks, I'll give that a try. It is currently using the latest msbuild from vs 2017. I don't understand what causes the v4.0.xxxx to be referenced. External Program Failed: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MsBuild.exe (return code was 1)
How are you "building the solution"? It is a bit confusing because you seem to indicate that it is "building correctly in VS 2017", but what are you doing when it is failing to build?
dotnet msbuild isn't able to build framework 4.6.x projects right? In my experimenting, dotnet msbuild can build the other 9 projects just fine, but then gets hung up on the wpf project.
I'm trying to get it build on our build server using TeamCity for continuous integration.
@Reg Do you have tried build your WPF project with MSBuild directly without on TeamCity Service? If it could build only with MSBuild that doesn't on TeamCity Build Server, the problem should be more related to TeamCity. In addition, could you share the detailed steps to help us reproduce this issue?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.