NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 252 forks source link

Support Xdt on `<PackageReference />` #12209

Open John0King opened 1 year ago

John0King commented 1 year ago

NuGet Product(s) Involved

dotnet.exe

The Elevator Pitch

package.config support web.config.install.xdt and now <PackageReference /> loss this feature

Additional Context and Details

I know that there no much that the xml file in the new .Net web project , but there still a web.config in asp.net core web project, and the PackageReference is also be used in old project that target .net 461

kartheekp-ms commented 1 year ago

As mentioned in docs, note clearly suggests that if you add the XDT transforms files to your package, consumers using your package with PackageReference will not have the transformations applied (refer to this sample to make XDT transforms work with PackageReference).

Can you please refer the example and check if it works in your case?

ghost commented 1 year ago

This issue has been automatically marked as stale because we have not received a response in 14 days. It will be closed if no further activity occurs within another 14 days of this comment.

John0King commented 1 year ago

that's too complicated, and there no solution for existing nuget package.

jeffkl commented 1 year ago

Team Triage: Unfortunately when using PackageReference there is no code run from the package during installation like there was with packages.config. It is very unlikely that we will be updating the product to support this scenario since a workaround is available.

John0King commented 1 year ago

Why Can't we add a Task after Restore ?

jeffkl commented 1 year ago

Why Can't we add a Task after Restore ?

As far as I understand it, when installing a package in Visual Studio with this XDT functionality, the web.config was modified once and only once during the installation process. Restore happens many many times so it would also need to be sure not to modify the web.config over and over. Also, we think its not great to have Restore modify your projects' files. Instead, it makes more sense to have this config file customization to happen at build time when the original web.config is being modified as part of compilation and build output. All of that functionality is out of scope for NuGet and would need to be part of the .NET SDK. Alternatively, a 3rd party NuGet package could provide generic functionality to make web.config modifications during build as described in the sample.