question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

msbuild cannot build new style csproj when targetting net462

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
rainersigwaldcommented, Jun 20, 2018

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.

2reactions
Amit-Kumar-Sonkarcommented, Jun 28, 2018

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’.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build errors with version conflicts (.net 4.6.2 and . ...
Building the solution locally with the latest visual studio update is working, only in combination ... xxx\xxx.csproj' targets 'net462'.
Read more >
MSBuild reference for .NET SDK projects
Reference for the MSBuild properties and items that are understood by ... For more information, see Target frameworks in SDK-style projects.
Read more >
Build succeeded with projects Ctrl + Shift + B that MSBuild ...
MSB4078: The project file 'MyProject.csproj' is not supported by MSBuild and cannot be built? My project is running with Target Framework .Net ...
Read more >
Upgrading an existing .NET project files to the lean new ...
They are effectively MSBuild files that orchestrate the build process. Phrased differently, a csproj file is an instance of an MSBuild file.
Read more >
Multi-targetting .Net Framework and .Net Core in a single project
The new csproj file is a fraction of the complexity of the old-style projects, and it handles both NetFramework and NetCore very simply....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found