Visual Studio 2017 build agent fails to build with error cs0400

Artak

I've installed the VS 2017 Build agent and registered it in the 'Default' agent queue. The project I'm trying to build is a VS 2017 class library project, targeting .Net Standard 1.0. When building from Visual Studio, build succeeds. However the build on the build agent fails.

T16:05:59.0389362Z ##[error]C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp.NETStandard,Version=v1.0.AssemblyAttributes.cs(4,20): Error CS0400: The type or namespace name 'System' could not be found in the global namespace (are you missing an assembly reference?)

By comparing the build logs with my local build I can see that the build agent calls the csc.exe with missing 'reference' attributes. My project has no any explicit references - it just requires .NetStandard 1.0 libraries (SDK). The command line the build agent uses is:

\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1705 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE;RELEASE;NETSTANDARD1_0 /debug- /debug:portable /filealign:512 /nologo /optimize+ /out:obj\Release\netstandard1.0\Geo.Common.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Team Tools\Static Analysis Tools\Rule Sets\MinimumRecommendedRules.ruleset" /target:library /warnaserror- /utf8output /deterministic+ Distance.cs DistanceExtensions.cs GeoCoordinate.cs Unit.cs "C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp.NETStandard,Version=v1.0.AssemblyAttributes.cs" obj\Release\netstandard1.0\Geo.Common.AssemblyInfo.cs

I know I can just hardcode the 'reference' list as command line attributes to the build step in build definition, but that's a workaround. What is the right way to fix this ?

Thanks!

UPDATE Turned out that the reason for the failure was that the earlier step in the build definition, the NuGet Restore was using the 3.5 version of nuget.exe. Because the project file was in VS 2017 format, nuget.exe was unable to find any referenced packages, so was completing successfully without actually pulling anything in. Thus, on the next step, the build was failing as no NuGet packages (hence any assemblies) were found.

SOLUTION

I downloaded nuget.exe 4.0 (found here) and place it in the agent's work directory (D:\VsAgentWork\nuget.exe in my case). Then, I customized the NuGet Restore step, to reference the nuget.exe from the provided location (....\nuget.exe).

Chris Patterson

You need to restore you package for your solution. For .NET Core you need to either do this with the dotnet cli or with the MSBuild /t:restore target or you can download NuGet 4 from the nuget site and put that on your build machine and specify it in the path on the NuGet installer task.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

TFS 2017 - Build Agent Connection Error - Failed to Connect

分類Dev

Visual Studio 2017 dotnet crash when changing target build

分類Dev

Visual Studio 2017 - Post build exited with code 9009

分類Dev

Using Cmake to build ssh.dll with Visual Studio 2017

分類Dev

Visual Studio2017をTeamFoundation Server Build Agentに追加するにはどうすればよいですか?

分類Dev

Visual Studio 2012 Fails To Build New Project That References Other Projects

分類Dev

SSIS Project Fails To Build On Self Hosted Agent

分類Dev

How do I Properly run NPM Install in Visual Studio Team Services Build Agent

分類Dev

Visual Studio 2013, error MSB8020: The build tools for Visual Studio 2010 cannot be found

分類Dev

Pre-Build/Post-Build Events in Visual Studio for Mac

分類Dev

Rename a TeamCity Build Agent

分類Dev

visual studio 2013 hide build progress window

分類Dev

cmake + qt + visual studio: moc objects on build

分類Dev

Visual studio Online build services, git tag

分類Dev

Visual Studio command line build arguments

分類Dev

Visual Studio 2017 debug error: "Frame not in module"

分類Dev

CUDA 9 unsupported error with Visual Studio 2017

分類Dev

Visual Studio 2017 "error" prevents editing of form

分類Dev

error Build: File 'COMPUTE_PATHS_ONLY.ts' not found in visual studio

分類Dev

Visual Studio 2015 (C++) : Stop compile on first build error (not first project)

分類Dev

Visual Studio build error "This version of NuGet.exe is not compatible with the version of Windows you're running."

分類Dev

Gradle build error in Android Studio 3.1.3.2

分類Dev

Android Studio hangs / Freezes when project build fails

分類Dev

Android Studio build works, Gradle command line fails

分類Dev

Android Studio Fails to Build Without Cast, But App Crashes With Cast

分類Dev

Cannot register a build agent in VSTS

分類Dev

GRUB build fails to compile

分類Dev

Build fails with Fakes assembly

分類Dev

Visual Studio 2017 crash

Related 関連記事

  1. 1

    TFS 2017 - Build Agent Connection Error - Failed to Connect

  2. 2

    Visual Studio 2017 dotnet crash when changing target build

  3. 3

    Visual Studio 2017 - Post build exited with code 9009

  4. 4

    Using Cmake to build ssh.dll with Visual Studio 2017

  5. 5

    Visual Studio2017をTeamFoundation Server Build Agentに追加するにはどうすればよいですか?

  6. 6

    Visual Studio 2012 Fails To Build New Project That References Other Projects

  7. 7

    SSIS Project Fails To Build On Self Hosted Agent

  8. 8

    How do I Properly run NPM Install in Visual Studio Team Services Build Agent

  9. 9

    Visual Studio 2013, error MSB8020: The build tools for Visual Studio 2010 cannot be found

  10. 10

    Pre-Build/Post-Build Events in Visual Studio for Mac

  11. 11

    Rename a TeamCity Build Agent

  12. 12

    visual studio 2013 hide build progress window

  13. 13

    cmake + qt + visual studio: moc objects on build

  14. 14

    Visual studio Online build services, git tag

  15. 15

    Visual Studio command line build arguments

  16. 16

    Visual Studio 2017 debug error: "Frame not in module"

  17. 17

    CUDA 9 unsupported error with Visual Studio 2017

  18. 18

    Visual Studio 2017 "error" prevents editing of form

  19. 19

    error Build: File 'COMPUTE_PATHS_ONLY.ts' not found in visual studio

  20. 20

    Visual Studio 2015 (C++) : Stop compile on first build error (not first project)

  21. 21

    Visual Studio build error "This version of NuGet.exe is not compatible with the version of Windows you're running."

  22. 22

    Gradle build error in Android Studio 3.1.3.2

  23. 23

    Android Studio hangs / Freezes when project build fails

  24. 24

    Android Studio build works, Gradle command line fails

  25. 25

    Android Studio Fails to Build Without Cast, But App Crashes With Cast

  26. 26

    Cannot register a build agent in VSTS

  27. 27

    GRUB build fails to compile

  28. 28

    Build fails with Fakes assembly

  29. 29

    Visual Studio 2017 crash

ホットタグ

アーカイブ