NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

Azure DevOps msbuild pipeline only works with Nuget 4.7 restore, not 5.x #9640

Open Adebeer opened 4 years ago

Adebeer commented 4 years ago

Upgraded nuget packages in Service fabric solution containing mix of .net core 3.1 and .net 4.7.2 projects. On Azure DevOps MS Build for sln fails with misleading Error NETSDK1004: Assets file 'D:\a\1\s\Src\myproj\obj\project.assets.json' not found when using Nuget 5.x, however works fine with Nuget 4.7. My other Service fabric solutions consisting of pure .net standard/core projects work fine on 5.x.

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe):

In Azure DevOps build pipeline, using NuGet 5.x via tool installer (v.0.169.1 task) - which installed 5.6.0, followed by "Nuget restore" (v2.169.1 task) - nuget.exe version 5.6.0.6.591. followed by "dotnet restore" (v.2.169.1 task) MSBuild version 16.6.0.22303 Note: above works if I change installer to use Nuget v4.7

VS version (if appropriate): 2017

OS version: Azure pipelines - windows-2019 hosted agent

Worked before? If so, with which NuGet version: Always worked with 4.7, but after spending (many hours) upgrading nuget packages and converting to newer PackageReference - it made sense to use 5.x as I do in my other newer SF projects. It's only after reverting back to nuget 4.7 that it worked.

## Detailed repro steps so we can see the same problem

Likely can reproduce this issue by creating a blank/default Service Fabric solution containing 1 .net core 3.1. stateless service, 1 .net 4.7.2 ASP.NET web api stateless service and one .net 4.7.1 class library in one project.

## Other suggested things

I did extensive googling - some people seem to suggested:

Aside: Other unhelpful things I noticed as part of converting to new packagereference format:

### Verbose Logs

This is error I get as part of buidling solution file:

Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 6/2/2020 6:21:29 AM.
##[debug]Processed: ##vso[task.logdetail id=ea7f895b-dd05-4964-82a4-7edb722e4c2f;parentid=59292472-c9ee-4885-81dc-277963dfcaea;name=Als.Gel.Next.sln;type=Build;starttime=2020-06-02T06:21:30.0533577Z;state=InProgress;]
Project "D:\a\1\s\Src\Als.Gel.Next.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Release|x64".
##[debug]Processed: ##vso[task.logdetail id=8ba3c694-6460-4bc2-9359-81205e989a18;parentid=ea7f895b-dd05-4964-82a4-7edb722e4c2f;name=Als.Gel.Next.WebApi\Als.Gel.Next.WebApi.csproj.metaproj;type=Build;starttime=2020-06-02T06:21:30.1626837Z;state=InProgress;]
##[debug]Processed: ##vso[task.logdetail id=1b820730-e6ed-4027-9326-ee142998d8b6;parentid=8ba3c694-6460-4bc2-9359-81205e989a18;name=Bootstrapper\Bootstrapper.csproj;type=Build;starttime=2020-06-02T06:21:30.5077450Z;state=InProgress;]
Project "D:\a\1\s\Src\Als.Gel.Next.sln" (1) is building "D:\a\1\s\Src\Als.Gel.Next.WebApi\Als.Gel.Next.WebApi.csproj.metaproj" (2) on node 1 (default targets).
Project "D:\a\1\s\Src\Als.Gel.Next.WebApi\Als.Gel.Next.WebApi.csproj.metaproj" (2) is building "D:\a\1\s\Src\Bootstrapper\Bootstrapper.csproj" (3) on node 1 (default targets).
PrepareForBuild:
  Creating directory "bin\x64\Release\netcoreapp3.1\win7-x64\".
  Creating directory "obj\x64\Release\netcoreapp3.1\win7-x64\".
##[error]C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(234,5): Error NETSDK1004: Assets file 'D:\a\1\s\Src\Bootstrapper\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
##[debug]Processed: ##vso[task.logissue type=Error;sourcepath=C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets;linenumber=234;columnnumber=5;code=NETSDK1004;]Assets file 'D:\a\1\s\Src\Bootstrapper\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1004: Assets file 'D:\a\1\s\Src\Bootstrapper\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [D:\a\1\s\Src\Bootstrapper\Bootstrapper.csproj]
##[debug]Processed: ##vso[task.logdetail id=1b820730-e6ed-4027-9326-ee142998d8b6;parentid=8ba3c694-6460-4bc2-9359-81205e989a18;type=Build;result=Failed;finishtime=2020-06-02T06:21:31.4171330Z;progress=100;state=Completed;parentid=8ba3c694-6460-4bc2-9359-81205e989a18;name=;]
Done Building Project "D:\a\1\s\Src\Bootstrapper\Bootstrapper.csproj" (default targets) -- FAILED.
##[debug]Processed: ##vso[task.logdetail id=8ba3c694-6460-4bc2-9359-81205e989a18;parentid=ea7f895b-dd05-4964-82a4-7edb722e4c2f;type=Build;result=Failed;finishtime=2020-06-02T06:21:31.4344155Z;progress=100;state=Completed;parentid=ea7f895b-dd05-4964-82a4-7edb722e4c2f;name=;]
Done Building Project "D:\a\1\s\Src\Als.Gel.Next.WebApi\Als.Gel.Next.WebApi.csproj.metaproj" (default targets) -- FAILED.
##[debug]Processed: ##vso[task.logdetail id=ea7f895b-dd05-4964-82a4-7edb722e4c2f;parentid=59292472-c9ee-4885-81dc-277963dfcaea;type=Build;result=Failed;finishtime=2020-06-02T06:21:31.4344155Z;progress=100;state=Completed;parentid=59292472-c9ee-4885-81dc-277963dfcaea;name=;]
Done Building Project "D:\a\1\s\Src\Als.Gel.Next.sln" (default targets) -- FAILED.

Build FAILED.

gel.next.azuredevopsLogFile.txt.zip

rrelyea commented 4 years ago

Does service fabric support conversion of their projects to sdk style projects? Or to projects with PackageReference? Can you please give us repro steps on how we could create it...ideally, start with file/new project -- or with a repro in a repo?

Adebeer commented 4 years ago

@rrelyea Thanks Rob. As far as I can tell, the sfproj file only supports packages.config approach, however all other microservices part of this solution can use either approach as per general .net

When creating a new Azure DevOps pipeline using classic editor (not using yaml) and you apply the the Azure Service Fabric Application template, it defaults to Nuget 4.4.1 - so I suggest reaching out to the Microsoft Service Fabric team as it seems to be a known issue.

Aside: I haven't tried yaml approach as there is no default/template supporting Service Fabric.