publish vs package via tfsbuild - visual-studio

I am currently integrating in web deploy package publish via visual studio and tfs bulid 2010 and have some questions:
For different environments, is a Publish profile needed for each?
As part of the publish is it possible to execute a generated database against a database?
Within the publish profile is it possible to create an application pool, web site, configure it etc if it doesn't previously exist?
Re tfs build - is it possible to click a button to deploy a successful build based on a selected publish profile?
Thanks for any feedback!

I know you're trying to use webdeploy, although most enterprise architecture will use other tooling. I suggest using powershell remoting tools. This gives you the full power of the .NET framework to do database deployments using whatever tools you want.
I usually create different transforms to transform the configuration files. Depending on what environment you deploy to you can use the appropriate transform that matches your environment or manipulate the transform as desired.

Related

Clarification on correct usage of TFS to publish Web Application

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

Create a web deploy package outside visual studio source code

I'm trying to create web deploy packages through visual studio team services.
Currently, I have created a web deploy publish profile in Visual Studio. I use MSBuild in Visual Studio Team Services to build the solution and create a web deploy package. I then zip the package and save it to a shared location. However, the issue with this approach is that it does not provide me a way have a same build for different environments. Let us say, I created a web deploy package for DEV environment. Then when I have to deploy the build to SIT environment, I would need to build the solution again and create a package. This way I would have different builds for different environments. I would like to have the same build get promoted to different environment for better traceability and maintenance.
One way I feel I can achieve this is to have a separate build definition for just building the application and save the DLLs to a shared location. I can then have a separate build definition which takes the build from shared location and create a web deploy package from the build. How can I achieve that on VSTS?
Other way possible is creating a label when any deployment happens one environment, say Dev environment. To do the deployment in SIT I can use the source code with same label and then use MSBuild to create a web deployment package. Is there any way to achieve this through VSTS with/ without creating a separate build definition of each environment?
Any other suggestions than above?
You can use VSTS Release Management to deploy your deployment package to different environment and use "Tokenizer" task in Release Management Utility tasks to update the config file in the package base on the variable for different environment configurations.
And you can also try with Web Deploy Parameterization.

How to deploy Azure WebJob using different configurations for different environments in Visual Studio

We have several Web Apps and WebJobs with different configurations for different environment, e.g. Test and Release.
Each WebJob is deployed to a Web App using "Publish as Azure WebJob" in Visual Studio.
We are using the Config Transform extension to transform the App.config that consist of different config sections, connection strings and app settings that needs to be transformed. This works fine for local Debug and for Release.
The problem is that when we use "Publish as Azure WebJob" there is no way to specify which configuration to use and Release is always built and published even if Test is selected inside Visual Studio.
We have also tried to deploy the WebJob together with the Web App but it almost always hangs, same as described in Stuck when publishing Web App to Azure with WebJob
We don't need to use config transform if that's not possible, e.g. we could configure directly in Azure. But I haven't found a way to configure config sections directly in Azure.
Yes this is a known VS tooling pain point that comes up often. The short answer is that web.config style transforms aren't supported for general application types like Console apps.
This has been discussed recently in the context of WebJobs in our public repo here. That issue also links to the VS User Voice issue for this. That item also links to the SlowCheetah VS extension which some users have said works for them. You might give that a try.
If that doesn't work for you, then you'll have to manually manage your settings via the app settings blade in the Azure portal.
I added a prebuild step to change the webjob-publishing-setting.json file and the app.config file depending on which Configuration is selected.
The webjob-publishing-settings.json only had the name. Then from Visual Studio 2019 I used "Publish as Azure WebJob" and that created a second webjob with the new name and new configuration.
Works great!

How to deploy to sharepoint?

Been working some with SharePoint 2010 for a litle while and it feels like my deployment method is way to slow and way to complicated, so my question is basically..
Is there anyway for me to deploy a package to a remote sharepoint server directly from Visual studio?..
For instance.. could I some how create a connection between my visual studio project and the sharepoint server I want to deploy to and then simply press some kind of "Deploy-button" that then deploys the whole project(or even better just my changes) against the remote sharepoint-server?
Thanks in advance!
This won't be easy. Firstly there is the Deploy option which you have for every SharePoint project. This deploys the Solution (WSP) to the URL you specified under Site URL for the project. However this won't help you in your case because it only deploys to a local SharePoint Server.
There simply is no automated way to deploy to a remote server from within Visual Studio. What you are talking about actually has aspects of Continuous Integration -> Continuously wanting to deploy on each check-in.
The perfect tool for continuous integration is the Team Foundation Server. There you will have the possibility to create a deployment script (via a TFS workflow) which automatically increases the version number of your assemblies as well as deploys them to a remote SharePoint server. This usually is done via PowerShell remoting.
PowerShell is the keyword here as in the end you could create your own PowerShell deploy scripts and just call them in the Visual Studio Post-Build instead of using a full fledged TFS.

How do I handle builds of Web Application Projects in VS 2012 without Web Deployment Projects?

My team uses Team City to do continuous builds and deployment of our Web Application Projects. In order to do a deployment build, we use Web Deployment Projects, which are not available in Visual Studio 2012. We aren't really using any of the advanced features of WDPs like .config transformations, but the main reason we use them is because when they build, they put only the necessary files for deployment into the build folder - in essence, removing all the .cs files and leaving only what's needed for "xcopy deployment". We then rsync the result to our test/prod environments.
So, my question is this: now that WDPs are no longer supported in Visual Studio 2012, how do I do an automated deployment build that pares down to only the files needed for deployment in VS2012?
Web Deployment Projects have been superseded by Publishing Profiles in VS2012.
They can do everything WDPs can do, with the added advantage of not needing to install additional software or create a separate .WDP project file.
Doug Rathbone has done a great blog post on migrating to Publishing Profiles from WDP:
http://www.diaryofaninja.com/blog/2012/08/26/visual-studio-2012-web-deployment-projects-are-dead-ndash-long-live-publishing-profiles
You should look into Octopus, it gives you all kind of deployment options. http://octopusdeploy.com/
Since .net 4.0 there is package and publish support in Web Application Projects out of the box. All you need is call msbuild /t:Package - it will do all the stuff.
I recommend to read this tutorial, there is everything you need. http://www.asp.net/web-forms/tutorials/deployment/deploying-web-applications-in-enterprise-scenarios/deploying-web-applications-in-enterprise-scenarios
We use Jenkins for our CI environment combined with SVN. In VS 2012 we check in code (using Ankh) to SVN and we configure Jenkins to poll SVN every 15 minutes:
Jenkins CI
Here's a post I wrote about setting up a CI server with IIS7 and Web Deploy 2.0:
Setup CI server with IIS7 and Web Deploy 2.0

Resources