Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can a NuGet package include transformations for both app.config and web.config?

I'm trying to create a nuget package which will both add a DLL and configure it inside of the proper configuration file. The package can be used in either a console/form application or a web application, so I want to update the appropriate configuration file, either app.config or web.config.

My files section in the .nuspec file contains the following inside of the section.

    <file src="config.transform" target="content\app.config.transform"/>
    <file src="config.transform" target="content\web.config.transform"/>

The .nupkg file does contain both of the transforms inside of the content folder.

When I add my package to a project in VS2010 through Manage NuGet Packages, the only file which is ever modified is the app.config file. Web.config is never touched. In fact, in a web application with an existing web config, NuGet will create an app.config file which contains the modifications.

Is there a way of doing what I'm trying to do (and if so, how)?

like image 823
Thierry Avatar asked Sep 25 '12 20:09

Thierry


People also ask

How do I create a new transformation in web config?

If you have a web application project, Right-click on web. config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both will get a transform added).

What about NuGet packages and packages config?

The packages. config file is used in some project types to maintain the list of packages referenced by the project. This allows NuGet to easily restore the project's dependencies when the project is to be transported to a different machine, such as a build server, without all those packages. If used, packages.

What is Web config transform?

A Web. config transformation file contains XML markup that specifies how to change the Web. config file when it is deployed. You can specify different changes for specific build configurations and for specific publish profiles.


1 Answers

According to a related bug report, it should already work how you want it to. Are you running the latest version of NuGet?

like image 102
Betty Avatar answered Nov 12 '22 07:11

Betty