0
votes

I am having problem converting my Portable C# projects to .Net Standard 2.0.

I have followed the method outlined by Adam Pedley in Upgrade PCL to .NET Standard Class Library and finally got everything working locally. However, when queuing on our build server I am faced with the following error:

C:\Program Files\dotnet\sdk\2.0.3\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(323,5): error : Assets file 'D:\Builds\Agent-57-01_work\11\s\MyProject\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [D:\Builds\Agent-57-01_work\11\s\MyProject\MyProject.csproj]

Our build servers are running agent version 2.120.2 and have Visual Studio 15.4.5. installed.

1
Does your build include a NuGet restore or does your MSbuid call include a /restore argument?Martin Ullrich
@MartinUllrich We had a NuGet Installer task set to version 3.0.0 of NuGet. Changing it to 4.0.0 fixed the issue.Tore Østergaard

1 Answers

1
votes

Please use the latest NuGet (you can try Nuget Version 4.3.0) to restore the packages.

If you are using VSTS, then you can use NuGet Tool Installer to install Nuget Version 4.3.0.

For TFS on-premise, just follow below workaround: (See Using the latest NuGet in your build for details.)

Because the NuGet Tool Installer is not available in TFS versions prior to TFS 2018, there is a recommended workaround to use versions of NuGet > 4.0.0 in Team Build.

  1. Add the task, if you haven’t already. If you have a “NuGet Restore” step in the catalog (it may be in the Deprecated tasks section), insert it into your build. Otherwise, insert a “NuGet” step.
  2. For your NuGet/NuGet Installer step, use the version selector under the task name to select version “0.*”.
  3. In the Advanced section, set the NuGet Version to “Custom” and the Path to NuGet.exe as $(Build.BinariesDirectory)\nuget.exe
  4. Before your NuGet step, add a “PowerShell” step, select “Inline Script” as the Type, enter this PowerShell script as the Inline Script, and enter “4.3.0” (or any version of NuGet from this list) as the Arguments.

Also reference below threads: