sdk: msbuild cannot build new style csproj when targetting net462

From @SidShetye on June 19, 2018 23:48

Steps to reproduce

Problem demo’d at the repo at https://github.com/SidShetye/msbuild-newcsproj-issue

Expected behavior

build the project like VS2017 gui does on the same machine

Actual behavior

build fails even though there are no nuget dependencies

Build FAILED.

    "C:\temp\new-old-proj-mix-soln\ClassLibraryFw462NewProj\ClassLibraryFw462NewProj.csproj" (build target) (1) ->
    (ResolvePackageAssets target) ->
        C:\Program Files\dotnet\sdk\2.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): error :
    Assets file 'C:\temp\new-old-proj-mix-soln\ClassLibraryFw462NewProj\obj\project.assets.json' not found. Run a NuGet package restore
        to generate this file. [C:\temp\new-old-proj-mix-soln\ClassLibraryFw462NewProj\ClassLibraryFw462NewProj.csproj]

    0 Warning(s)
    1 Error(s)

Environment data

msbuild /version output:

Microsoft (R) Build Engine version 15.7.179.6572 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
15.7.179.6572

OS info: Win 10 x64 v1803 (OS Build 17134.112) VS 2017 (15.7.4)

Copied from original issue: Microsoft/msbuild#3429

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 17 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks for the detailed report!

All projects that use Microsoft.NET.Sdk require NuGet restore before build. You can accomplish this with a small change to your build script:

diff --git a/DemoProblem.ps1 b/DemoProblem.ps1
index ae1b278..fbcee89 100644
--- a/DemoProblem.ps1
+++ b/DemoProblem.ps1
@@ -37,7 +37,7 @@ gci . -Recurse -Include bin,obj | % { ri -Recurse -Force $_.FullName }
 # And now it barfs :/
 # building in VS2017 (15.7.4) works just fine though
 $cwd=$PSScriptRoot # just point to current directory / soln dir
-msbuild .\ClassLibraryFw462NewProj\ClassLibraryFw462NewProj.csproj /p:SolutionDir=$cwd /p:Configuration=Debug /m /t:build
+msbuild .\ClassLibraryFw462NewProj\ClassLibraryFw462NewProj.csproj /p:SolutionDir=$cwd /p:Configuration=Debug /m /t:build /restore
 
 # dump our msbuild version too
 msbuild /version
\ No newline at end of file

The VS build does NuGet restore independently and silently, which is why it works transparently.

what are the way to resolve below Issues while Build is going on from VSTS ?? even after ran dotnet build, dotnet restore not able to fix . ??

dotnetbuild

C:\Program Files\dotnet\sdk\2.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): Error : Assets file ‘D:\a\3\s\obj\project.assets.json’ not found. Run a NuGet package restore to generate this file.

Process ‘msbuild.exe’ exited with code ‘1’.

I am having same issues on AzureDevOps pipeline after updating my projects to .net core 2.2.

well Finally we were able to resolve the TFS BUILD Issue 🥇 from Command Line and TFS

FROM COMMAND LINE : ) success build

FROM TFS : ) successful build

Now we were trying to DEPLOY Asp.Net Core Website after successful BUILD AND RELEASE..

stucked somewhere in Deployment let see…