question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:

image

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:open
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
matthidcommented, Jun 6, 2018

Ah okey, than I’m all in 😉

0reactions
0x53Acommented, Jun 6, 2018

I think we are saying the same thing, that there should be an explicit check, and an explicit error?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing nuget packages error while using msbuild from ...
This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, ...
Read more >
Walkthrough: Use MSBuild
Learn the various parts of an MSBuild project file, including items, item metadata, properties, targets, and tasks.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found