✅ Restore a PackageReference and use contained MSBBuild scripts inside of .targets file
Hey folks,
I have a CICD script that executes a custom target
Foo.targets
using dotnet msbuild Foot.targets /t:DoSomething
The script pretty much looks like this
The target is trying to use other targets and variables that are defined within the CustomBuildTargets
nuget package. However since the this is a .target
file and not a csproj
I can't use restore. Is there a way to go about doing this?
Things I have attempted>
1. -t:Restore=true
2. GeneratePathProperty and trying to get the path to the build
folder in the nuget pakcage3 Replies
i would not use a plain targets file for this
the PackageReference does nothing here
you don't import or run the NuGet targets so nothing uses it. you might as well have typed
<Blablabla Include="CustomBuildTargets" />
what i think you probably want is to use the Microsoft.Build.NoTargets
SDK
https://github.com/microsoft/MSBuildSdks/tree/main/src/NoTargets. it imports all of the SDK logic but doesn't actually do anything inside the compile target
so, you would define a Foo.msbuildproj
that looks something like: and then dotnet build
itoh that is really intresting! I have never played around with the NoTargets. I will take a gander at that. Thank you
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.