locked
VSTS Build is failing with error 'Error : CS0246, Error : CS0518 and json' not found. Run a NuGet package restore to generate this file' RRS feed

  • Question

  • Hi,

    As specified in the subject, VSTS Build is failing with error 'Error : CS0246, Error : CS0518 and json' not found. Run a NuGet package restore to generate this file',

    to explain in deep about the issue, We have included 'NuGet Restore' version 1.* in our build definition with default setting, when we queue the build 'NugetRestore' task is completing, but Build is failing with below errors and exceptions, So we requires some guidance or work around to fix this issue.

    Errors Details : 

    ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(154,5): Error : Assets file 'd:\a\1\s\Main\MoE.ERS\Main\Applications\MoE.Infrastructure\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.

    ##[error]------------------Tests.Services.AssemblyInfo.cs(21,12): Error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
    ##[error]-----------------.Tests.Services.AssemblyInfo.cs(17,59): Error CS0518: Predefined type 'System.String' is not defined or imported

    ##[error]Process 'msbuild.exe' exited with code '1'


    Sham Sundar.G

    Wednesday, June 7, 2017 8:42 AM

All replies

  • This is a dotnet project. So, you should use “dotnet restore” and not “nuget restore”. Try using the dotnet core template (which uses dotnet restore).

    If you are using authenticated nuget feeds, then you can use nuget restore but you also need to use nuget installer task. See https://github.com/Microsoft/vsts-tasks/issues/3762 for a discussion on that.

    Do click on "Mark as Answer" on the post that helps you, this can be beneficial to other community members.

    • Proposed as answer by Swikruti Bose Wednesday, June 7, 2017 5:52 PM
    Wednesday, June 7, 2017 5:51 PM