6

I've been pulling my hair out on this for a while now. I'm trying to implement a continuous integration and deployment pipeline using TeamCity and Octopus Deploy. I am 99% there, except for one problem. I am using the standard msbuild runner of teamcity, configured to use the version 12 of msbuild.

I need to include the web.config transforms in the published output so they can be packaged into a nuget package for octopus deploy. I do not want the transforms to be applied by msbuild.

I am not using Octopack to create packages. I'm using the built-in teamcity nuget packager. So I'm publishing the website to a filesystem folder and then creating the package from the files in this folder. However, no matter what I do I cannot get msbuild to include the web.config transform files in the publish (I am using Octopus Deploy to perform the transforms, so I don't want msbuild to perform them).

I have verified that all the transform files (Web.Release.config, etc..) are marked as "Content". I have NOT marked them to copy always, because doing this copies them to the bin folder, not the root folder where they belong.

I have removed the /p:Configuration= property from the msbuild command line as I've read that is required for transforms to be applied. my parameters to msbuild look like this:

/p:DeployOnBuild=true /p:PublishProfile=Deployment

There is nothing in the publish profile that seems to relate to transforms. The publish profile contains the filesystem location to publish to.

Any suggestions here?

Note: I've given up and found a different solution, but I'm leaving this open in case anyone has any input.

Erik Funkenbusch
  • 90,480
  • 27
  • 178
  • 274
  • See [this answer](http://stackoverflow.com/questions/2747081/how-do-you-include-additional-files-using-vs2010-web-deployment-packages). I believe that if you place these elements into your publish profile file and adjust the paths accordingly, you will be able to output your web.environment.config files to the publish output. – NightOwl888 May 23 '16 at 20:34
  • @NightOwl888 - seems like an awfully intrusive process. I'm worried about Visual Studio overwriting these changes by developers who aren't aware of what's going on. – Erik Funkenbusch May 23 '16 at 21:00
  • There are many cases where manual edits to MSBuild files are required. Visual Studio only supports a subset of the functionality of MSBuild (including the most useful feature of MSBuild, the condition attribute). In general Visual Studio ignores XML elements and attributes it doesn't have UI editors built for (except in files where it warns not to edit near the top). However, you might want to comment the sections you add manually so changes to them can be spotted easily via diff view windows when checking in project files as an insurance policy. – NightOwl888 May 23 '16 at 21:40
  • @NightOwl888 - I finally gave up, and figured out a solution that uses variable replacement in octopus deploy, thanks for your help – Erik Funkenbusch May 23 '16 at 22:54
  • 1
    I'm facing this as well. My client has created transforms already for all their projects, and currently creating one build per environment, I'm trying to consolidate and use Octopus. I'm looking now to have a manual step that copies the configs into the folder created by publish before creating the nuGet package - but this seems like a pain – fuzzbone Sep 25 '17 at 18:07

1 Answers1

0

You could create a custom .nuspec file and reference the files that you want to include from there.

My suggestion would be to have the .nuspec file in the same directory as the web.config / web.release.config files, and make the paths relative from there.

So if you publish to a directory called /output you could use rules like this

<files>
  <file src="*.config" target="\" />
  <file src="publish\*.*" target="\" />
</files>

So nuget pack nuspecPath would become the way to pack the project

NuSpec Reference

Hope this helps

Evolve Software Ltd
  • 3,525
  • 1
  • 14
  • 18