I have .NET452 project - lets call it Consumer.csproj
that I want to consume nuget lets call it SharedTargets
that contained some custom targets files (SharedTargets.targets
) from msbuild.
I'm using PackageReference
format and now (compared to what it used to be) nuget packages are being restored to shared folder (%userprofile%.nuget\packages), and I'm not sure if it is good idea to reference it via that (doesn't feel right).
Eg:
<PackageReference Include="SharedTargets">
<Version>1.0</Version>
</PackageReference>
<Import
Project="$(USERPROFILE)\.nuget\packages\SharedTargets\1.0\SharedTargets.targets"
/>
Also this works only in VS, running this from command line (msbuild
) I'm getting chicken-egg problem:
Confirm that the path in the
<Import>
declaration is correct, and that the file exists on disk.
Obviously since I need to restore nuget first before I can use it :)
So question:
- is there some more elegant way how to resolve path to the nuget package inside project file
- is there a way how to make msbuild succeed (i.e. restore packages before
SharedTargets.target
is imported)