Nuget pack renames web.config to web.config.transform

I have a problem with nuget pack renaming web.config to web.config.transform in my project. I am using the csproj file with the nuspec file next to it and there is no line in the nuspec file to tell nuget to rename the file, but in the output file and nupkg file web.config is renamed to web.config. conversion.

web.config is not part of the project, it is just added by the nuspec file (as usual, it is generated by the build process)

Can someone suggest why he does this - he feels to me like an error in nuget, but maybe there is something in the csproj file that nuget accepts as an instruction for renaming? What could it be?

Command:

nuget pack path\to\projectfile\myproject.csproj -OutputDirectory C:\temp\publish -Version 1.1.646.32517 -Exclude Template.config -Exclude Template.Debug.config -Exclude Template.Release.config -Verbosity detailed 

output:

 Attempting to build package from 'myproject.csproj'. Packing files from 'path\to\projectfile\bin'. Using 'myproject.nuspec' for metadata. Add file 'path\to\projectfile\bin\myproject.dll' to package as 'lib\net451\myproject.dll' Add file ... to package as ... ... Found packages.config. Using packages listed as dependencies Id: myproject Version: 1.1.646.32517 Authors: xxx Description: myproject Dependencies: Microsoft.AspNet.WebApi (= 5.2.3) Added file 'content\ApiTestPage.html'. Added file ........ ..... Added file 'content\Web.config.transform'. Added file 'lib\net451\myproject.dll'. Successfully created package 'C:\temp\publish\myproject.1.1.646.32517.nupkg'. 

Nuspec file:

 <?xml version="1.0"?> <package > <metadata> <id>$id$</id> <version>$version$</version> <title>$title$</title> <authors>$author$</authors> <owners>$author$</owners> <description>$description$</description> <requireLicenseAcceptance>false</requireLicenseAcceptance> <releaseNotes>xxx release.</releaseNotes> <copyright>Copyright xxx 2015</copyright> </metadata> <files> <file src="bin\*.*" target="content\bin" /> <file src="web.config" target="content" /> </files> </package> 

Thank you in advance

Chris

+6
source share
1 answer

Having the same problem, I solved this by explicitly adding Web.config to my nuspec file.

 <package > <metadata> ... </metadata> <files> <file src="Web.config" target = ""/> </files> </package> 

When I first noticed this problem, I also noticed that IIS now works from the package root, not from /content , so I solved it (reluctantly) by moving my content to the package root. If you don't have this problem, <file src="Web.config" target = "content"/> may be better for you.

For completeness, the file section of my nuspec (due to moving content to the root directory) is as follows.

  <files> <file src="Web.config" target = ""/> <file src="*.asmx" target = ""/> <file src="*.asax" target = ""/> <file src="*.html" target = ""/> <file src="bin\*.dll" target="bin" /> </files> 
+1
source

Source: https://habr.com/ru/post/985107/


All Articles