I am using CruiseControl.Net for my continuous integration process. Using ccnet I build and publish my asp.net application into a server in Release mode. But I am not able to change debug="true" to debug="false" in my Web.Config during publishing. What can I do?
You might consider using a Web Deployment Project (WDP) which can be run as part of your visual studio build configuration. The WDP will handle things like toggling the debug setting and it change any environment-specific web.config settings as well. Here's a WDP tutorial.
If you are calling a msbuild script from ccnet you could use the XmlUpdate task from the MSBuild Community Tasks Project.
<XmlUpdate
XPath="/configuration/system.web/compilation/#debug"
XmlFileName="$(WebConfigFileFullPath)"
Value="false" />
I documented my build process here if you are interested.
Expanding on Tom Brothers' answer above, we use the <XmlMassUpdate> task in MSBuild Community Tasks to merge a deployment-specific web.config that contains multiple changes to apply to the base web.config to change the debug setting, connection strings, logging configuration, etc. So a web project contains web.config with the configuration necessary to run from the development machines. There's also web.Release.config file which contains only the changes that we need to apply to web.config to produce the configuration on the production web server.
Since the extra file only contains changes (deltas) to apply to web.config, it's not very big. Visual Studio ignores it during development, and CruiseControl.Net applies the changes to web.config when it gets deployed to the web server.
Related
I'm trying to setup CI via TFS 2015, I've got a solution that has got 2 main Web application that currently we deploy manually editing the config files and so on (which sometimes leads to errors)
I've read about build/release process and in the past I've used Jenkins as build server. But till today I've got a question and that's related to when apply the transformation of XML config files.
In my current VTFS2015 setup I've created a build process and I build the project with the following line
msbuild /p:Configuration=Test /p:PublishProfile=Test /p:DeployOnBuild=true xxx\xxx.csproj
This creates me in the folder obj\Test\Package\PackageTmp the package
Is this ok? or should this be done in the release management tab? Consider in my farm I've
Test (from DEV trunk)
Staging (from Dev trunk as well)
Production (from production trunk on 3 machines)
My goal is to have them automatically delivered on the machines, but I don't know the right moment to apply the transformation (during the build I can use the publish feature, during the RM I can use a ps1 script)
Thanks in advance
Well, I think this thread will helps: What TFS 2017 build task applies web.config transforms during TFS builds?
To apply the transformations you can use the extension: Apply transformations in vNext build process.
Usually it should be a package and be used in a deploy task such as
Deploy: WinRM - IIS Web App Deployment or Azure App Service
Deployment to achieved the deployment.
1) Can transforms be engaged in both Builds and Releases?
Yes, you could also do this in a build pipeline with the useage of build deploy task. You need to add the task after the publish build
artifacts task.
2) Does TFS 2017 require a lot of special handling to engage a
transform file?
update
The BuildConfiguration variable is different in TFS 2017, it's inside
the MSBuild task! Transforms are now applied according
to the MSBuild task Configuration setting.
Edit the .proj file is a method to do the transform. If you don't need to change the transform, it will auto do it during the build.You
could also use some 3-rd party task/extension for extra transform such
as: XDT Transform
Usually we separate the build and release for the deployment, cause
it's easy to configure multiple environments and easy to debug issue.
You definitely could do this only in build but with a bloated process.
You could refer this tutorial: Build and Deploy Azure Web Apps using
Team Foundation Server/Services vNext Builds.
For a separate build and release solution, you could take a look at
this blog: Using web.config transforms and Release Manager – TFS
2017/Team Services edition
I have a web api project and I want have different web.config build when I switch to say "release" and build.
In the past for window services I used on the app.config SlowCheetah and when I would build it would build whatever was selected in the dropdown(ie debug/release).
I read something that web.configs don't need slowCheeta but when I use the dropdown, change to release and look in the bin folder it is not using the release web.config.
How can I make this work?
Bonus would be if I could do it on debugging as well.
I am using the new VSTS release management to deploy my website to Azure web app. All I want is to transform one connection string for QA environment. I am finding it hard to get answer for that. Any help is much appreciated.
I don't want to create tokens in my web config file because I want to use the config file as such in my local environment.
You can also use the VSTS variable which contains the connectionstring to deploy as a connectionstring to an Azure WebApp.
This looks like a shameless plug for my open source VSTS task. But it is a clean and easy solution for your problem. My task can be used to deploy appsettings and connectionstrings configured as variables in VSTS to deploy to an Azure webapp. Without changing the web.config.
Take a look in the marketplace to install it in VSTS and for the documentation: https://marketplace.visualstudio.com/items?itemName=pascalnaber.PascalNaber-Xpirit-WebAppConfiguration
Storing connection strings (other than the local dev ones) on a source control is far from being a best practice from a security perspective.
The build/release management system allows you to have secret variables and/or services endpoints you can reuse in your flow.
However you should look into the publish commutator in the build step (MSBuild arguments), that will ask to visual studio to do the publish and apply transformations from the config transform files and publishing profile.
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.stagingDirectory)"
This is what I put in my MSBuild Arguments on a Visual Studio Build task on my build definition and it works like a champ:
/p:DeployOnBuild=True;PublishProfile="$(BuildConfiguration)" /p:publishUrl="$(Build.ArtifactStagingDirectory)" /p:DeleteExistingFiles=True /p:WebPublishMethod=FileSystem /p:DeployDefaultTarget=WebPublish
Note that I have BuildConfiguration as a variable which corresponds to UAT or Release or Dev for example. The PublishProfile corresponds to a Publish Profile you've set up in your project/solution. (So, if you name your Publish Profile "Hey-Go-To-Dev" then you'd put "Hey-Go-To-Dev" in the BuildConfiguration (or a new variable you can set up).
Anyway: This will execute your publish profile and do any related transforms in your web.config file(s).
Godspeed.
I installed Visual Studio Web Deployment Projects 2010 and added a deployment project to my solution. When I build the deployment project, it does not apply the web.config transform file for the specified configuration.
My web app project has the following files:
Web.config
Web.Debug.config
Web.Release.config
Web.Stage.config
I have tried to check the "Enable web.config file section replacement" but that seems to not make a difference. I even tried checking "Use external configuration source file" but that didn't make a difference either.
I've tested the config files using MSBuild from the command line and they work as expected.
Do web deployment projects support config transformations? If so, how do I get them to work?
I was unable to get this to work and used Web Deploy functionality instead. Web deploy supports web.config transforms and seems to be a bit more flexible than web deployment projects.
I'm facing quite a problem while setting up automated TFS Builds. Basically I created new configuration called Tests, added transform config, defined different connection strings for the Database. Then defined TFS build, building whole solution with MSBuild arguments /p:DeployOnBuild=True /p:Configuration=Tests.
The problem is that in the drop location (Build_PublishedWebsites\Project) I get web.config, web.debug.config, web.release.config and web.tests.config, however I would expect just one transformed web.config.
I already checked PDC presentation Web Deployment Painkillers: Microsoft Visual Studio 2010 & MS Deploy but didn't help.
Thanks for any answer.
Web.config transforms are part of the new Web Publishing Pipeline (WPP) in Visual Studio 2010.
During the build process the "CopyWebApplication" target is executed to copy the website to the _Websites folder on the build output directory. Due to backwards compatibility reasons, MSBuild uses the "old" (VS2008) copy behavior by default and not the new WPP system.
To opt-in to using WPP, set the following MSBuild properties:
/p:UseWPP_CopyWebApplication=True
/p:PipelineDependsOnBuild=False