添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dear all,

I have .Net Core project which has been converted with Visual Studio 2017.
The build plan especially the task NuGet Restore worked for that one before the migration.

Afterwards the build fails with the error:
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(154,5): Error : Assets file '[path_to_project_on_agent]\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.

May you please check and if possible fix this?

Best regards, matthias

matttrakker, norcino, channaj, netoisc, bunnywrote, firatesmer, OutSorcerer, and ankurkapoor reacted with thumbs up emoji tomtheisen, old-coder-404, kizylirio, FrankV01, Winner244, and UFFR reacted with confused emoji All reactions

Here's how to enable tool installers (what @alexmullans referred to above)

https://youtu.be/Ie8EuvqJ0Hg

I think nuget one should be there now. If not, coming to your scale unit soon.

@bryanmacfarlane The url doesn't have any video content.

I tried to use NuGet 4.0 and that results in this build error

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build* netstandard1.0 *\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(124,7): Error MSB4184: The expression "[System.IO.Path]::GetDirectoryName('')" cannot be evaluated. The path is not of a legal form.

My project is netcoreapp1.1 and .NET 4.5.2

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>
  <PropertyGroup>
    <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
  </PropertyGroup>

Edit: Using NuGet 3.5.0 I get another error message

2017-05-05T07:13:47.3908531Z [command]C:\a\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.31\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe restore -NonInteractive C:\a\1\s\i2M.WebApp.sln
2017-05-05T07:13:49.5013000Z Failed to load msbuild Toolset
2017-05-05T07:13:49.5013000Z   Could not load file or assembly 'Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
2017-05-05T07:13:49.5256477Z ##[debug]rc:1
2017-05-05T07:13:49.5256477Z ##[debug]success:false
2017-05-05T07:13:49.5336572Z ##[error]Error: C:\a\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.31\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe failed with return code: 1
2017-05-05T07:13:49.5336572Z ##[debug]Processed: ##vso[task.issue type=error;]Error: C:\a\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.31\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe failed with return code: 1
2017-05-05T07:13:49.5336572Z ##[debug]task result: Failed
2017-05-05T07:13:49.5346515Z ##[error]Packages failed to install
          

@alexmullans I disabled the **uGet restore**-task and replaced it with **dotnet restore** (arguments /.csproj`) and that step is running to completion but the build step is failing.

Will try to replace it with dotnet build

Update It works with dotnet build. Now time to tackle Publish to Azure (next step after test) why the .zip is created. Not a perfect template for ASP.NET Core since it doesn't work very well...

Update 2
So after properly building all projects but not creating a zip I tried to pass arguments to dotnet build namely /p:DeployOnBuild=true /p:PackageAsSingleFile=true /p:WebPublishMethod=Package /p:PackageLocation=$(build.artifactstagingdirectory). Then I got the error message below.

017-05-08T11:55:45.9195458Z C:\Program Files\dotnet\sdk\1.0.2\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(137,5): warning MSB3371: The file "\i2M.WebApp.SourceManifest.xml" cannot be created. Access to the path 'C:\i2M.WebApp.SourceManifest.xml' is denied. [C:\a\1\s\src\i2M.WebApp\i2M.WebApp.csproj]
2017-05-08T11:55:45.9195458Z C:\Program Files\dotnet\sdk\1.0.2\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(137,5): warning MSB3371: The file "\i2M.WebApp.Parameters.xml" cannot be created. Access to the path 'C:\i2M.WebApp.Parameters.xml' is denied. [C:\a\1\s\src\i2M.WebApp\i2M.WebApp.csproj]
2017-05-08T11:55:45.9365468Z C:\Program Files\dotnet\sdk\1.0.2\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(162,5): error MSB4062: The "CreateManifestFile" task could not be loaded from the assembly C:\Program Files\dotnet\sdk\1.0.2\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\..\..\tools\netcoreapp1.0\\Microsoft.NETCore.Sdk.Publish.Tasks.dll.  Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [C:\a\1\s\src\i2M.WebApp\i2M.WebApp.csproj]

Update 3
Removed the DeployOnBuild and now it builds propertly but the zip is stille nowhere to be found when the deploy step is running. Getting closer at least...

2017-05-08T11:08:05.5484278Z Build FAILED.
2017-05-08T11:08:05.5524283Z 
2017-05-08T11:08:05.5534280Z "C:\a\1\s\i2M.WebApp.sln" (default target) (1) ->
2017-05-08T11:08:05.5534280Z "C:\a\1\s\src\i2M.WebApp\i2M.WebApp.csproj" (default target) (2) ->
2017-05-08T11:08:05.5534280Z "C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj" (default target) (3:2) ->
2017-05-08T11:08:05.5534280Z (CoreCompile target) -> 
2017-05-08T11:08:05.5534280Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(14,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5534280Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(15,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5534280Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(16,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(17,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(18,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(19,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(20,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.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?) [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(14,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(15,61): error CS0518: Predefined type 'System.String' is not defined or imported [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(16,59): error CS0518: Predefined type 'System.String' is not defined or imported [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(17,59): error CS0518: Predefined type 'System.String' is not defined or imported [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(18,68): error CS0518: Predefined type 'System.String' is not defined or imported [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(19,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(20,53): error CS0518: Predefined type 'System.String' is not defined or imported [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(21,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(11,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5544291Z   obj\Debug\netstandard1.4\i2M.Domain.AssemblyInfo.cs(12,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5584611Z 
2017-05-08T11:08:05.5584611Z 
2017-05-08T11:08:05.5584611Z "C:\a\1\s\i2M.WebApp.sln" (default target) (1) ->
2017-05-08T11:08:05.5584611Z "C:\a\1\s\src\i2M.WebApp\i2M.WebApp.csproj" (default target) (2) ->
2017-05-08T11:08:05.5584611Z "C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj" (default target) (3:2) ->
2017-05-08T11:08:05.5584611Z (GenerateBuildDependencyFile target) -> 
2017-05-08T11:08:05.5584611Z   C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(92,5): error : Assets file 'C:\a\1\s\src\i2M.Domain\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\a\1\s\src\i2M.Domain\i2M.Domain.csproj]
2017-05-08T11:08:05.5584611Z 
2017-05-08T11:08:05.5584611Z 
2017-05-08T11:08:05.5584611Z "C:\a\1\s\i2M.WebApp.sln" (default target) (1) ->
2017-05-08T11:08:05.5584611Z "C:\a\1\s\src\i2M.WebApp\i2M.WebApp.csproj" (default target) (2) ->
2017-05-08T11:08:05.5584611Z   C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(92,5): error : Assets file 'C:\a\1\s\src\i2M.WebApp\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\a\1\s\src\i2M.WebApp\i2M.WebApp.csproj]
2017-05-08T11:08:05.5584611Z 
2017-05-08T11:08:05.5584611Z 
2017-05-08T11:08:05.5584611Z "C:\a\1\s\i2M.WebApp.sln" (default target) (1) ->
2017-05-08T11:08:05.5584611Z "C:\a\1\s\test\i2M.WebApp.Tests\i2M.WebApp.Tests.csproj" (default target) (4) ->
2017-05-08T11:08:05.5584611Z   C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(92,5): error : Assets file 'C:\a\1\s\test\i2M.WebApp.Tests\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\a\1\s\test\i2M.WebApp.Tests\i2M.WebApp.Tests.csproj]
2017-05-08T11:08:05.5584611Z 
2017-05-08T11:08:05.5584611Z     0 Warning(s)
2017-05-08T11:08:05.5584611Z     21 Error(s)
2017-05-08T11:08:05.5624547Z 
          

dotnet restore is the right thing to use here. In an upcoming sprint, we'll be updating the dotnet task to work with authenticated feeds.

If you need authenticated feed support with .NET Core projects today, there are two steps:

  • Add a NuGet Tool Installer task to your build and specify version 4.1.0.
  • Add a NuGet task to your build, select the restore command, and configure the task appropriately for your solution/project.
  • I need to use .NET Core with authenticated VSTS nuget feed? I am getting a 401 error now. How do i authenticate with user name and VSTS PAT?
    C:\Program Files\dotnet\sdk\2.0.0\NuGet.targets(102,5): error : Unable to load the service index for source https://vsts.url.com/nuget/v3/index.json. [d:\a\1\s\myproject.csproj]
    2017-09-05T15:06:52.4907364Z C:\Program Files\dotnet\sdk\2.0.0\NuGet.targets(102,5): error : Response status code does not indicate success: 401 (Unauthorized). [d:\a\1\s\myproject.csproj]

    I'm facing the exact same issue. I tried many ways but the build is still failing.
    I've created a stack-overflow question.
    https://stackoverflow.com/questions/46155449/use-vsts-to-build-a-solution-with-vsts-packages-and-old-style-csproj
    Thanks,

    dstj, jholt456, nmalyarsky, barelabs, BStrat77, and hyper4mance reacted with thumbs up emoji tjoudeh and Amit-Kumar-Sonkar reacted with hooray emoji jps, rsaa, and GuilhermeMorais reacted with heart emoji All reactions

    What if I am trying to build using docker image microsoft/aspnetcore:1.0-2.0 ?
    dotnet restore just ignores the credentials from nuget.config in the project/solution dir.
    Any way to build with private NuGet feeds?

    I'm not super-familiar with the docker image you referenced, but you might try passing the --configFile flag to the dotnet restore step in the container. Note that this will only use that config (i.e. it won't also include the machine-level nuget.config that contains nuget.org), so you'll need to add a line in the config for nuget.org if you use packages from there.

    Yet another one of those amazing GitHub threads that pops up when you Google some absurd issue with the buggy Visual-Studio-Of-The-Week drop.

    @alexmullans self-assigns the bug, closes it before a fix is shipped, and here it sits for months.

    See this over and over in Microsoft's absurd use of GitHub. Stop it!

    Hey guys, i know this is closed but I have an existing solution that I recently added a brand new nodejs project to (using the out of the box template from VS) ... I told it to add that to source control and attempted a check in to which the build server (delegated by VSTS, all up to date with VS 2017 and nuget 4.6) responded with this ...

    2018-03-20T14:34:17.4906031Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(154,5): Error : Assets file 'C:\BuildAgent\_work\1\s\Dev\Shell\NodeApp\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.

    based on the advice given above I added a dotnet restore command following the get sources step and it made no difference ... same exception.

    Is there a patch expected for this or a work around?

    from above dated july 12th 2017 ... @alexmullans ...

    Closing this for now. The updated dotnet task (with support for authenticated feeds) should land in the next deployment (3.5ish weeks). Please keep an eye out for that and give it a shot.

    ... still looks pretty broken to me :(

    I also noticed some weird stuff ...
    The dotnet step / command asks for "path to project(s)" and a build step asks for "Solution".
    The former i noticed is attaching the pattern match as a physical path search where as the latter is expecting a virtual path.
    Can you guys please try to be more consistent in the future, perhaps it might be best to always use virtual paths?

    @TehWardy are you using dotnet restore and then Visual Studio Build? Not sure that'll work. You'll probably want to use either NuGet + Visual Studio Build (for .NET Framework projects) or dotnet restore and dotnet build (for .NET Core projects). Solution is a concept in .NET Framework that is mostly unused in .NET Core, which is why the different tasks use different text.

    If that still doesn't work, please feel free to open a question on Developer Community.

    oh ok ... I use VS build and did have a nuget restore step in the process prior to adding a dotnet restore step.

    I've noticed all my old solution even if I do a clean up of the build cache on the build server seems to build fine without a nuget or dotnet restore step in the process ... in fact a nuget restore step comes up with build warnings actively saying "dot use this, it's redundant".

    Either way both restoration steps result in the same build failure.
    I'll raise my question over on the dev community but this feels like a bug to me as dotnet core projects appear to not work in the same way that older dot net projects worked "out of the box" with a standard VS build step.

    Just remove the local repo from
    C:\Users\<username>\Documents\Visual Studio 2017\Projects\Chromely\src\nuget.config
    with a text-editor, and it will work.

    @abhijeetsinha9 This was solved a while ago ...
    These days I don't do a restore at all for .Net core projects I just do a build or publish and that does the restore for you.

    There is a bit of a gotcha though ... if using cloud based build servers provided by Microsoft they change the versions of .Net Core often as a result of ongoing progress so if you don't keep up you start to find older projects break.
    The fix is simply to migrate your project to the latest .Net Core version.