Discussion: Nuget-Parity: Check for missing MSBuild Imports
See original GitHub issue.targets files get included conditionally, so that they don’t error out if they don’t exists.
<Import Project="..\packages\PepitaPackage\build\$(__paket__PepitaPackage_targets).targets" Condition="Exists('..\packages\PepitaPackage\build\$(__paket__PepitaPackage_targets).targets')" Label="Paket" />
On the other hand, this means that should for some reason the file not exist, it will just be silently ignored.
The conditional import is required so that the projects can be opened in Visual Studio before package restore, otherwise VS would pop open a message box.
For this reason, nuget creates a Task which checks on build time that the imports exist:
The nuget check looks like this:
<Import Project="..\packages\PepitaPackage.1.21.4\build\PepitaPackage.targets" Condition="Exists('..\packages\PepitaPackage.1.21.4\build\PepitaPackage.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\PepitaPackage.1.21.4\build\PepitaPackage.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\PepitaPackage.1.21.4\build\PepitaPackage.targets'))" />
</Target>
What do you think, would it make sense to replicate this functionality in Paket? I was hit by this and it took me a few minutes to figure out why a build didn’t work.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
Ah okey, than I’m all in 😉
I think we are saying the same thing, that there should be an explicit check, and an explicit error?