1
votes

Background

I recently converted my Xamarin.Forms app from PCL to Net Standard format. All of my projects now use PackageReference in the csproj file. Which means no more package.config or package.json.

We use TFS 2015 to build, sign, package our .ipa and .apk files. After conversion, the default MSBUILD build steps do not work as they look for mdtool and the new Visual Studio has vstool instead. So, I updated the build steps to use new tools via command line.

All my projects are NetStandard now (including iOS and Android).

Issue

I can successfully restore NuGet packages using restore MySolution.sln -force on Mac build server. But when I run vstool build MySolution.sln after that, I get this error:

error: NuGet packages need to be restored before building. NuGet MSBuild targets are missing and are needed for building. The NuGet MSBuild targets are generated when the NuGet packages are restored.

I am able to successfully run the nuget restore and vstool build locally on the build machine. But only when TFS runs the command via agent, it shows that error message.

Setup

Builds: TFS 2015 on Mac agent running Visual Studio 7.5

2
Mmm, not sure what TFS is doing differently. The error message is from the .NET Core extension in VS for Mac. This error happens when the extension checks that the obj/project.assets.json file exist. This file should be generated when a restore is run. You could try switching to use msbuild instead of vstool to run the build. You can also use msbuild /t:restore yoursolution.sln to restore a .NET Standard project.Matt Ward
msbuild /t:restore My.sln fails with error, /NuGet.targets(104,5): error : '1.0.0$(rev:r)' is not a valid version string. on all Net Standard projects. (which is the version set by my build configuration) so, using nuget restore My.sln only restores PCL packages. It shows the warning, NETCore and UAP projects will be skipped, only packages.config files will be restored. Also, no bin and obj folders exist on the server because restore and build fails.hnabbasi

2 Answers

0
votes

According to the error and your description, you need also check if your build agent has corresponding capability to support vsbuild.

Take a look at this related question MacOS - Visual Studio Support and give a try with this workaround:

As a work around we set the Xamarin.iOS variable manually in the build agent and changed the mdtool path in the Xamarin iOS Build step to "/Applications/Visual Studio.app/Contents/MacOS/vstool".

Besides you could also try to use the suggestion from Matt in the comment above.

0
votes

Ok. I was finally able to get a successful iOS build on Mac server. This is the setup that works,

  • Using PackageReference in iOS .csproj
  • No package.config, project.json, or AssemblyInfo.cs file.
  • Running nuget restore .sln before building the iOS project.
  • Build solution using <path-to-vstool>\vstool build .sln -c:<configuration>

Now, I am working on the Windows machine for Android setup. Once I have that working, I will post my findings here.