Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nuget pack renames web.config to web.config.transform

Tags:

nuget

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

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

Can anyone suggest why it's doing this - it feels to me like a bug in nuget, but maybe there is something in the csproj file which nuget is taking as an instruction to do the rename? What could that 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>

Thanks in advance

Chris

like image 876
ChrisH Avatar asked Apr 14 '15 09:04

ChrisH


1 Answers

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

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

When I first spotted this issue, I also noticed that IIS was now serving from the root of the package rather than /content, so I solved this (reluctantly) by moving my content into the root of the package. If you don't have this issue, then <file src="Web.config" target = "content"/> may be a better fit for you.

For completeness, the files section of my nuspec (due to moving content to the root) is now 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>
like image 103
Andy Joiner Avatar answered Oct 25 '22 11:10

Andy Joiner