This project is read-only.

Projects using MSBuildVersioning from NuGet fail to load.


We just ran into a small fly in the ointment if using the NuGet version of MSBuildVersioning in Visual Studio 2013.

If the MsBuildVersioning package is not placed under source control, then when a developer checks out the source code for the first time any projects that reference MsBuildVersioning will fail to load (because obviously the MsBuildVersioning folder doesn't exist, so the <Import /> declaration fails to find the MsBuildVersioning.targets file from the reference folder).

If the developer goes to NuGet and selects "Manage packages for solution", then NuGet will detect that some packages are missing and provide a "Restore" button to retrieve them. Unfortunately, MSBuildVersioning is not among the packages that get restored (because the project files could not be loaded successfully due to the missing MSBuildVersioning dll).

As currently implemented, the only "easy" way for a developer to restore MSBuildVersioning capability using NuGet is to add the reference to an assembly in the solution that does not currently use it. Having done that, they can reload the affected project(s) and finally remove the MSBuildVersioning reference from the assembly to which it was temporarily added.

A better option may be to modify the <Import /> tag to include a condition checking for the existence of MsBuildVersioning.targets before loading it. (I.e the import tag should read as follows: <Import Project="..\packages\MSBuildVersioning.\lib\net35\MsBuildVersioning.targets" Condition="Exists('..\packages\MSBuildVersioning.\lib\net35\MsBuildVersioning.targets')" /> ). This allows the project to load successfully. When built, the NuGet package restore will be triggered, and by the time the project is actually built the appropriate libraries will be available.

All the best!