Search code examples
nuget.net-standard-2.0xdt-transform

Are xdt transforms not supported in nuget packages installed in a netstandard 2.0 project?


I have a nuget package that has .xdt transforms for a app.config file. The xdt files are included in the netstandard 2.0 project that builds the nuget package. Their build action is set to content/do not copy. When I install the package in a .net framework project, the xdt transforms work corectly, but when I install the package in a netstandard 2.0 project, the xdt files do not transform the config file, but instead are added to the project with a build action of C# Compiler. Does nuget not support xdt transforms on netstandard projects?


Solution

  • You are right, xdt transforms aren't supported in PackageReference environment. This includes both sdk-based projects as well as classic .net framework projects using PackageReference instead of packages.config. You can follow this GitHub issue for more details. There is also a sample package that shows how to use build-time logic to apply transforms instead to work in all environments.

    Also note that .NET Standard and .NET Core projects don't have an app.config file that a transform could apply to. This is only relevant for .NET Framework / classic Web Applications. (with maybe an exception for IIS settings for ASP.NET Core apps but they don't affect the app itself, only IIS hosting environment).