web.config transform for environments without build configurations - octopus-deploy

I really like the ability of visual studio 2012 to be able to preview a transform along with a comparison with the original web.config. But in order for this to work, the transforms must be created based on build configurations.
is there a way to be able to preview transforms in the same way, without having to create build configurations for each environment?
(for deployment i use octopus deploy so there is no need for these transforms to work with publish functionality provided by vs)

Found it! You can create a publish profile with the same name as the transformation config name, and the preview transform will work, without having a build configuration for it.
The cool thing is that you don't have to actually use the publish profile (publish the application)... just save the pubxml andd voila right click on transform -> preview transform!
Read More: http://sedodream.com/PermaLink,guid,fdcc88bf-95ac-4945-a49b-96d9d1ac35a5.aspx

Related

Why are config transforms not applied when I manually publish a console app as an Azure webjob?

I have a console application that I am deploying to Azure as a Web Job. I do this manually from Visual Studio 2015 by right-clicking the project and choosing "Publish as Azure WebJob".
I am now at a point where I need to deploy this app to several different environments (ex: dev, test, prod etc). In each environment the console app needs to run with different config settings.
To get this done, I've installed Slow Cheetah v2.5.48 and setup multiple config transform files - one for each environment.
I've also created dedicated publish profiles in my project - one for each environment - and I've made sure the profile names match the names of the config transform files.
When I manually publish via the Publish wizard in VS (as described above), I find that the config transforms are not applied. Instead, the "base" .config file are present on the target app service.
Why are the transforms not applied when publishing this way and how can I fix that?
According to your description, I suggest you could firstly check you have already build configuration called "dev" ,” test” like below.
Then I suggest you could check you have a right app config file in your project like below.
At last, you could make sure you have select the right build configuration.
Besides, I suggest you could open your .csproj file and ensure that the App.dev.config tag’s IsTransformFile is true.
<None Include="App.dev.config">
<DependentUpon>App.config</DependentUpon>
<IsTransformFile>True</IsTransformFile>
</None>
I would suggest you try with:
< xdt:Transform="Replace">

How to publish ClickOnce application using build definition?

I'm currently publishing the ClickOnce application manually by right clicking .csproj. Is there a way I can do the same from the solution directly so that I can use it with the build definition for continuous integration?
You can't publish the ClickOnce application from solution directly, but you can build and publish ClickOnce application with both XAML build and vNext build, and use MSBuild argument “/target:publish” to make MSBuild create the ClickOnce publish folder. Here are two blogs with detailed steps to build and publish ClickOnce application:
Build and Publish a ClickOnce App using Team Build/VSO, please refer to blog: http://blogs.msdn.com/b/tfssetup/archive/2015/09/15/build-and-publish-a-clickonce-app-using-team-build-vso.aspx
Building ClickOnce apps using build vNext, please refer to blog: http://blogs.msdn.com/b/tfssetup/archive/2015/10/15/building-clickonce-apps-using-build-vnext.aspx
Assuming you are using XAML build, so I'd like to highlight the points in the blog with XAML build. To achieve build and publish a ClickOnce application using Team Build, you need to edit the XAML build definition with following steps:
Set the publish path in the properties of the project, which would correspond to the destination. Then checkin your project to TFS.
Create a copy of template TFVCTemplate.12.xaml to do customization. In order to make the build process get a few environment data, you need to:
Create two environment variables – DropLocation and WorkingDirectory.
Add two events of type GetEnvironmentVariable from the tool box. Add them any place you prefer within the flow.
Use the first to set the variable DropLocation with data “Microsoft.TeamFoundation.Build.Activities.Extensions.WellKnownEnvironmentVariables.DropLocation”.
Use the second variable to set the variable WorkingDirectory with data “Microsoft.TeamFoundation.Build.Activities.Extensions.WellKnownEnvironmentVariables.BuildDirectory”.
Create new argument of type DestinationLocation and set to In with type String. This would be used to hold the location (file location) where your end data is going to go.
The reason we are editing the XAML build definition is the way ClickOnce publishing is done by MsBuild. MSBuild publish doesn’t do the copy of files to the destination, it creates a folder within bin and puts the files there.
As by default TFS copies the bin folder to the output drop location. But we need the app.publish folder. In order to find a way to take the published files from the publish folder. You need to:
Search for “Copy binaries to drop” activity within the template.
In the properties over write the existing source location(which would be the bin folder, like WorkingDirectory + "\src\Desktop\TeamAdmin\ClickOnceTest\ClickOnceTest) to something like this – WorkingDirectory + "\src\Desktop\TeamAdmin\ClickOnceTest\ClickOnceTest\bin\Debug\app.publish".
Add an event CreateDirectory, to create the directory again. We can use the destination location variable we created before. And Copy the files from the drop location to the desired location.
Now we can create a new build definition and enter the value for the DestinationLocation and the MSBuildArguments “/target:publish” and queue the build.

How can you transform an app.config from a second transform specification?

How can you transform an app.config from a second transform specification?
The existing SlowCheetah extension does a great job, but as far as I can see, it only works against the build configuration
But web applications can have two transforms, one for the build configuration and a second for the publish profile, which are applied to the original web.config
How can you replicate this for a desktop application with an app.config?
In Visual Studio there are two levels of transformations.
- Transform based on build configuration (i.e. web.release.config)
- Profile specific transforms
The idea being that if you need to share transforms across profiles you can create a new build config and define shared transforms and then you can create profile specific transforms for the items which are environment specific.
To create build config transforms, you can right click on web.config and select Add Transforms. To create a profile specific transform you can right click on the publish profile (.pubxml file under Properties\PublishProfiles). For more detailed info see the doc at http://www.asp.net/web-forms/overview/older-versions-getting-started/deployment-to-a-hosting-provider/deployment-to-a-hosting-provider-web-config-file-transformations-3-of-12

Validate C# project file against a template during build

I know that you can create a template project to ensure that certain required settings (for ex: code analysis, treat warnings as errors, platforms, etc.) are set in a new project.
I want to enforce this as a part of the CI process i.e. in the build I want to validate the C# project files against a template (or an XML file) and cause a build failure if the project files don't conform to it. I need suggestions and ideas on how this can be achieved.
I want to try this with TFS 2010 and VS 2010.
I am writing a custom task to search for all the C# project files and compare the Xml structure of the Template project file with the Actual project file and report any difference as error.
I usually tackle this by customizing my build process to run Code Analysis/StyleCop/etc against all projects regardless of project settings.
Likewise for Treat Warnings as Errors. I just override the proejct settings at the build-level so that no matter what people do to the projects I know that everything I want to run is being run at build time.

Make Debug/Release Build Configuration with 1 Click Publish dependent on the selected Publish Profile

This is almost a duplicate of Link build configuration to a publish profile, but that question was not answered...
I have 2 1 Click Publish configurations for my Web Application:
Test Server
Production Server
If I select Build => Configuration Manager => Release and then click the Publish button my application will be published with a release configuration (and visa versa) - without regard to the current Publish profile selected.
But what I REALLY want is...
To set the appropriate Build Configuration from the 1 Click Publish settings. Test Server should be published with my Debug settings and Production Server should be published with the Release settings.
I shouldn't have to make the change from within the Configuration Manager. But I Do.
So, I have 2 questions:
Am I just doing it wrong? Based on a little note in the Publish Settings stating "Use Build Configuration Manager to change configuration" this seems like this is exactly how it is intended to work.
Is there another way of having 2 publish profiles, one with a Debug config and one with a Release config?
The only thing I'm using the debug/release build configurations for is for my Config Transforms that have different connection strings. So, alternative, but still 1 Click, publishing solutions are acceptable. :-)
It's possible to do another way by having multiple Web Deployment Packages.
Basically create two different projects and each one will compile and set the asp.net build config and output. Then script the deployment as part of it.
Bit hacky (wish the publish profiles could set the build config as you wished).
Other than that I normally do via powershell scripts and kick off from my desktop deploy that does all the appropriate compiling and deployment scenarios.
http://msdn.microsoft.com/en-us/magazine/cc163448.aspx
http://johnnycoder.com/blog/2010/01/07/deploy-aspnet-web-applications-with-web-deployment-projects/
I was able to get this to work by installing the Visual Studio Web Publish Update. This update allows you to tie a build configuration to a specific publish profile.
http://msdn.microsoft.com/en-us/library/jj161045.aspx

Resources