-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PackageReference in msbuild\custom-task-code-generation\AppSettingStronglyTyped is not working #6610
Comments
You can somewhat work around this issue by adding this line to .csproj of the nuget project |
Thanks for the tip. With this approach, Microsoft.Build.Framework.dll, Microsoft.Build.Utilities.Core.dll, etc. are also included, judging by the comments in the example project, we want to avoid this |
The README on the project seems a bit outdated. Here's a different version that should address this issue. The trick is to add |
Yes, seems like a good solution, thanks @horato Solution
Final .csproj file should look like this:
P.S. I don't want to close the issue until the documentation is updated |
Issue description
The approaches used in the AppSettingStronglyTyped example no longer work for using NuGet packages in projects with MSBuild Tasks.
When creating a package containing MSBuild Tasks, you cannot use NuGet packages as in a regular ClassLibrary project; NuGet packages, or more precisely the dlls supplied with them, must be bundled with the final package.
To achieve these goals, AppSettingStronglyTyped uses
CopyProjectReferencesToPackage
Target:samples/msbuild/custom-task-code-generation/AppSettingStronglyTyped/AppSettingStronglyTyped/AppSettingStronglyTyped.csproj
Lines 41 to 48 in d51488e
However,
Microsoft.Extensions.DependencyInjection.dll
is not included in the final package.I expect that after running
dotnet package
.nupkg will havetasks\netstandard2.0\Microsoft.Extensions.DependencyInjection.dll
, but it doesn't. Which leads to an error loading the library during the build:Steps to reproduce
Sample to reproduce https://github.com/Tripletri/samples/pull/1, integration tests is falling on this commit.
Other thoughts
Since
CopyProjectReferencesToPackage
useReferenceCopyLocalPathsReferenceCopyLocalPaths
and@(ReferenceCopyLocalPaths)
is always empty, this may relate to dotnet/sdk#3662.As a workaround, I simply commit the external DLLs, reference them with
<Reference>
and manually copy them at build time.First of all, I'm interested in how to achieve this use of PackageReference in projects with MSBuild Tasks, especially with multi-targeting, since manually managing dependencies for all target frameworks is a headache.
Thanks in advice
Target framework
dotnet --info output
The text was updated successfully, but these errors were encountered: