Search code examples
nugetnuget-packageportable-class-library

Force NuGet pack to use short folder names for PCL projects


I'm having a problem with NuGet producing different output folders when run locally to the version on my build server.

When I build my PCL project locally (using nuget 2.8.6), the folder structure within the nuget package is:

lib
- portable-net45 win wpa81 wp80 MonoAndroid10 xamarinios10 MonoTouch10
  - HC.Common.dll

However when I build it on our build server (TeamCity, nuget 2.8.2) I get the following folders:

lib
- portable-Profile259
  - HC.Common.dll

How can I ensure that both builds output consistent folder structures? It makes switching between the "published" version and my test versions quite tricky as the reference paths do not match between versions.

Is there a way to force nuget to use the short "Profile259" name?


Solution

  • NuGet will normally replace the PCL profile with the individual target frameworks if it can determine them.

    On your build server it looks like you do not have the the PCL profile xml files installed so NuGet is not converting the directory. So I am assuming you are using NuGet pack YourProject.csproj. If you used NuGet pack YourNuGet.nuspec the directories in the .nupkg would be the same on both machines.

    I do not know of any NuGet package that uses a PCL directory of the form portable-Profile78 and I am surprised this works but it seems to. All NuGet packages with PCLs have directories of the form:

    portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10
    

    So to make them consistent on both machines you will need to either install the PCL profiles on the build server or use NuGet pack YourNuSpec.nuspec so that the directories are not renamed by NuGet.exe.