How to publish same ASP.NET MVC website to multiple location? - visual-studio-2010

I'm developing MVC site, that require to be publish for multiple (large number) hosting location (web.config transformation takes care of individual settings), each publish is configure as build profile i.e. Release (Clinet - 1 - US) and it's respective web.config transformation.
I'm looking for an solution to release and publish the project to multiple location using Publishing Profile/Build Profile/Web.Config (respective) Transformation.
Build Profile is already taking care of web.config transformation but I'm not able to figure out how to link publishing profile to build profile and automate the process.

Related

Build individual batch of projects from solution

I have a solution with multiple projects, 2 of which are the main projects. A .NET WinForms desktop app and an ASP.NET WebApi2.
I have defined a number of publish profiles in Server project, which currently I execute manually. Now, moving to an Azure build pipeline I have a couple of questions:
I create a new pipeline based on the ASP.NET template, which builds all the projects within the solution. Should I leave as is, or should I exclude the client-side projects. If yes, then how can I achieve this?
I'm used to Visual Studio building and publishing just afterwards. In a CI/CD scenario, I assume that the I need to separate the building and publishing/deploying. Is this correct?
It all depends, you may use the same pipeline do build WinForms to create a package/installer. It is all up to you. If you want to exclude you may do it creating configuration
Configuration Manager -> Active Solution Configuration -> New ...
and then you will define what project you want to build. Next you will use this configuration in your build to just compile project you want.
You may pass configuration here.
If you use YAML pipeline instead of classic you may consider using multi stage pipeline. Here you have documentation and here a simple tutorial. If you decide to have one pipeline please check deployment jobs for deploying your app, however this is not necessary.
You you secleted classic pipeline you should go with classic release pipelines.

How to structure a Visual Studio project code base to be deployed to a number of websites with different config transformations?

An Umbraco Visual Studio solution with a single project acting as the core code base that is to be deployed to a number of websites. Each website will have it's own config file transformations, CSS, JS and View overrides. When the core code base is updated, this will need to be deployed to all of the websites.
I've toyed with the idea of separate repositories per website installing the core code base via a private NuGet package, but thought that might be quite time consuming as the number of websites grow, having to update each individual repository.
The ideally scenario in my head would be for the build server/client, GoCD, to somehow merge the core code base with each individual website and deploy accordingly.
Looking for any suggestions on how to approach this.

run release tasks selectively based on project code changes

We are using VSTS for build and release management, and using CI/CD. Typically, our solutions consist of a web application project, and a database project.
Our current release tasks take the application offline (using app_offline.htm), publish the database, then publish the web application. Publishing the database project often results in no changes, as due to CI/CD we are much more frequently updating code on the web app than changing the db schema.
Is there a way to only run the database publish task (using WinRM) when it detects a change in the database project code, in our git repository?
EDIT: This in itself isn't a problem, as typically when the DACPAC gets published, there will be no activity. HOWEVER, I've been requesting that the database is backed up using the /p:BackupDatabaseBeforeChanges=true flag - which seems to back up the database even if there are no changes. This is an issue for large databases.
The simple way is that you can separate web project and database project to two build definitions.
Create a new build definition
Enable Continuous Integration in Triggers tab
Specify Path filter to include database project
Modify Visual Studio Build task, specify /t:[database project name] argument in MSBuild Arguments box to just build database project
The same steps for web project
Create a new related definition
Add artifacts for previous two build definitions and enable Continuous deployment trigger
Add two environments (e.g. database, web)
Open Pre-deployment conditions of an environment (e.g. database)
Enable Artifact filters and select corresponding artifact (e.g. database build artifact), specify build branch (can specify *, it means all branches)
Add tasks to just deploy database in this environment
The same steps for web environment
The answer is - exactly what I want isn't possible.

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

Pre Build Events On A Website In VS2008?

I have a solution with multiple projects and a website. On each project I have set up a pre build event to get the highest subversion revision number of the project (using SubWCRev) and then replace part of the AssemblyVersion with that revision number.
How do I achieve this on a website? As far as I can tell there is no pre build event and if I try to:
Add another project
Make the website dependant on the project
Use the pre build event for the project
The subversion revision number used to replace information in the website will be for the project not the website.
Any ideas?
One suggestion might be to use a Web Application project - rather than a Web Site project. Although this might not be entirely feasible in your case, depending on the amount of work required to essentially migrate the existing code-base.
See this question and its answers for more information: ASP.NET Web Site or ASP.NET Web Application?

Resources