Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET project with project.json cannot be built

I have .net app, and I am trying to migrate from

packages.config to project.json .

Everything works fine when I build the project with Vs 2015 or manually using MsBuild from a command line. The problem starts to happen when I build it on build server with the setup:

  1. .NET 4.51 app
  2. MSBuild 14.0.25402.0
  3. Windows Server 2012
  4. Microsoft Build Tools 2013, 2015 RC installed.
  5. No Visual Studio installed.
  6. Nuget 3.4.3.855

When doing nuget restore project.lock.json is being created, packages are downloaded to user/.nuget/packages so it looks like it's doing the job. Then I am trying to run MSBuild, and I am getting a lot of reference errors:

error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)

When I use MSBuild from developer machine, I can build this project even if I point to build server directory so it's an obvious problem with MSBuild. I suppose that something is missing with Microsoft Build Tools, any ideas?

Edit: it looks like msbuild adds flag /reference with all nuget paths on my developer machine and it doesn't do it on build server machine. Example:

 /reference:C:\Users\user\.nuget\packages\log4net\1.2.10\lib\log4net.dll

Developer machine building the project:

Build started 27/06/2016 13:29:40.
Project "Y:\13dd0660b4e0a7a0\project.Shared.Utilities\project.Shared.Utilities.csproj" on node 1 (default targets).
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
  C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:C:\Users\username\.nuget\packages\EPPlus\4.0.4\lib\net20\EPPlus.dll

Build server msbuild building the same project

D:\13dd0660b4e0a7a0\project.Shared.Utilities>"C:\Program Files (x86)"\MSBuild\14.0\Bin\msbuild project.shared.utilities.csproj
Microsoft (R) Build Engine version 14.0.25123.0
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 27/06/2016 12:35:19.
Project "D:\13dd0660b4e0a7a0\project.Shared.Utilities\project.shared.utilities.csproj" on node 1 (default targets).
PrepareForBuild:
  Creating directory "bin\Debug\".
  Creating directory "obj\Debug\".
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
  C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.ComponentModel.DataAnnotations.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Configuration.dll" 

This is only part of the log -> as you can see /reference is passed to the first script

like image 472
MistyK Avatar asked May 18 '26 01:05

MistyK


1 Answers

I have found the solution. Copy content from developer machine to corresponding directory on your build server machine if missing.

C:\Program Files (x86)\MSBuild\Microsoft\NuGet

Not sure why this is missing after build tools 2015 installation.

like image 122
MistyK Avatar answered May 20 '26 14:05

MistyK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!