Closed JVimes closed 4 years ago
@dasMulli I tried your suggestion (thanks!) and made my nuget package put my targets file in Sdk\Sdk.targets
(I don't have a props file). But the target doesn't run, even without conditions. The .csproj looks the same as before. The docs don't look like what I'm doing, to my eye. Any ideas? 🤔
I think you’ll need a props file as well and then you don’t reference the package via NuGet (package reference) but extend the Sdk Attribute in your project to e.g "Microsoft.NET.Sdk;My.Package/1.2.3"
Maybe a full example helps..
Thanks, I wish that were acceptable but it sounds like it requires editing every .csproj by hand? Until multi-framework projects arrived, my coworkers just installed my NuGet package and it "just worked".
You can also create a Directory.Build.props file in your solution directory and put in:
<Project>
<Import Project="Sdk.targets" Sdk="Your.Pkg/1.2.3" />
</Project>
This file will be auto imported into every capris file in the hierarchy automatically.
The .csproj files are in different products (different codebases) and only select projects need the task. I can't think of a practical way to make use of Directory.Build.props. I appreciate the suggestions.
Duplicate of #2540
I need a task that:
The following works in the .csproj, or a .targets file directly imported by the .csproj. But it does not run in a .targets file brought in by a NuGet package.
Here's a stripped down version of my project:
Is there a way?