Web Deploy - How to create a package with selected items - visual-studio-2013

I would like to try the 'Web Deploy' method to deploy our website. Before my questions, I would like to provide a few details about the current deployment procedure:
It is an enterprise site & is hosted on multiple servers (with continuous deployment).
The files are not in 'Release' mode, but in 'Debug' mode.
We manually copy paste only the current assignment related files. Say, this week, the Accounts module is to be deployed, then the files to be deployed are
/mysite/App_Code/Models/accounts.cs
/mysite/pages/accounts.aspx, accounts.aspx.cs
The 3 files will be copied to the respective folders in all the servers manually. This has been the procedure for years here.
The project 'mysite' is an 'ASP.NET Website' and not 'ASP.NET Web Application' (in VS2013), which means these options are unavailable - Package/Publish Web & Package/Publish SQL
I have created the packages in the dev system,
(i) using the publish option(web deployment package) in Visual Studio and also
(ii) export application in IIS (gives the option to select the files)
Is it possible to create a package only for the files I need (in this case accounts.cs, accounts.aspx, accounts.aspx.cs), using VS publish feature.
Is it possible to include custom SQL scripts file in the package. (using IIS or VS)
If the answer is a Yes for Q2, then it should be executed only once, not for all servers. Because there is only one DB server. How can it be done.
I did not go for the Installing package part yet.

1 - Not through VS because there is no extension point (that I know of) into MSBuild for Websites. Sayed has a great post which describes how Websites are treated differently than Apps.
Alternative - You could copy the files you wish to deploy to a new folder and then use the MSDeploy.exe commandline tool to create a customer MSDeploy package which you can deploy to your server.
D:\temp>"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:contentPath=%cd%\DefaultWebSite\website1 -dest:package=DefaultWebSite.zip
Info: Updating MSDeploy.contentPath (MSDeploy.contentPath).
Info: Adding virtual path (D:\temp\DefaultWebSite\website1)
Info: Adding directory (D:\temp\DefaultWebSite\website1).
Total changes: 3 (2 added, 0 deleted, 1 updated, 0 parameters changed, 0 bytes c
opied)
D:\temp>"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package=DefaultWebSite.zip -dest:contentPath="Default Web Site\website2"
Info: Adding MSDeploy.contentPath (MSDeploy.contentPath).
Info: Adding virtual path (Default Web Site\website2)
Info: Adding directory (Default Web Site\website2).
Info: Adding file (Default Web Site\website2\Default.aspx).
Info: Adding file (Default Web Site\website2\Default.aspx.cs).
Info: Adding file (Default Web Site\website2\Web.config).
Total changes: 6 (6 added, 0 deleted, 0 updated, 0 parameters changed, 971 bytes
copied)
2/3 - Yes you could include SQL into the web deployment package but it would be deploy each time the package is deployed. We have found its better to seperate our SQL deployments into its own package so we can deploy it only when we want to.
This post describes how we handle our SQL deployments - https://dotnetcatch.com/2016/02/10/deploying-a-database-project-with-msdeploy/

Related

Which Umbraco folders do I need to backup after deploying from VS and adding to version control?

I did the following steps:
I have created a new Umbraco instance by using the nuget package and visual studio.
I have deployed to Azure, using Azure DB as backend.
Installed the articulate package.
Added my project to version control (including App_Plugins folder, articulate dlls and so on).
I am able delete the umbraco installation and I can restore it completely from version control including Articulate.
Now I am starting to add content, articles, pictures and so on.
Think I do not need to backup the whole folder on the web server. I am doing regular backups of my Azure DB and I need some folders which are also filled with new content, like
media (filling with pictures which I am adding to my articles)
App_Plugins (keeping installed packages in umbraco)
App_Data/packages (file directory for installed packages)
App_Data/umbraco.config (keeping some content for Articulate)
So, is this everything I need to be able to restore the whole system by using the version control part, azure db backup and the listed folders?
Ideally for data/contents you should backup media and App_Data folders. However, if you want to backup Umbraco site (including cache files) then I would recommend App_Plugins, App_Data, Bin, Config, Umbraco & Umbraco_Client folders.
Hope this information helps!
Basically I follow the approach as described in the question. I have added the following files and folders to the Visual Studio project and then later to version control (I have just expanded the more interesting folders which are not part of the project file by default, but needed when you redeploy the solution from scratch):
As described the backend is hosted on Azure SQL.
Open Live Writer makes it very easy to host article content on another ftp server.
By following this approach it is very easy to redeploy the complete solution, e.g. for umbraco upgrades or major changes on the site.

How to access tfs variables from a component using a custom powershell script for Visual Studio Release Management 2013 Release 4.0

My version of Visual Studio 2013 Release Management Client/Server is Release 4.0. I am using the ReleaseTfvcTemplate.12.xaml template. Is there any way to access the system variables from a release management component (deployer configuration) when using an AGENT based release template? I get NULL when I try to pass $applicationPath or $(applicationPath) or $(ApplicationPath).
Here is my status on the deployment of a component in RM that has a custom powershell deployment script:
I can successfully queue a release build
The build output is properly copied to \servername\BuildDrop\
I have an AGENT (not VNEXT) based RM template that gets triggered when the build is completed
The build properly triggers the RM template to release the build
This RM template has one component that gets deployed via a CUSTOM powershell script
The powershell script needs the full absolute path to the builddrop location in order to perform its work (what the powershell script does is not relevant to the discussion)
Example: In my deployment configuration for the component in RM, I need to pass the TFS build drop location without having to hardcode it
Based on the MSDN documentation there is a system variable $applicationPath which is hydrated by RM but ONLY when using VNEXT based templates, not Agent based templates
According to an accepted StackOverflow answer here related to accessing system variables from Agent Based RM templates, it would appear the MSDN documentation does not tell the whole story and I should be able to set a line in my component deployment configuration (See below)
As Graham mentioned in the comments, the build output is copied locally and it is your working directory when executing your Powershell.
You also can use this to access the build drop location: $(PackageLocation)
http://incyclesoftware.zendesk.com/entries/24422737-Deployment-Metadata
Just found a most recent and up to date post from Donovan Brown: http://donovanbrown.com/post/What-are-the-System-variables-for-PS-DSC-deployments-in-Release-Management.aspx

How to host updates for Clickonce applications?

When using Clickonce deployment when the publishing wizard in Visual Studio asks if the application will look for updates online (and if so, to provide a url) what exactly should I point to? Do I simply host the contents of the /publish folder on a server, and enter the url to that folder? Then just update the online /publish folder when I release updates, or should the url point to something else?
Normally the best way to host a ClickOnce Deployment is to deploy from a webserver.
On the first page in the Publish Wizard where it asks Specify the location to publish the application leave this as Publish\
On the second page where it asks 3 options select the top one marked From a Website and type in the url of the web server where you want to deploy from (this needs to be the full uri inc virtual directory).
Then complete the wizard.
What you should end up with is a series of files in the Publish directory, one of which will be publish.htm
You can then upload these files as is to your webserver and give out the link to the publish.htm file to let your users start the installer.
If you re-publish just keep the settings the same and you should roll out a new update to all those people who used the publish.htm link to install.

Visual Studio: Pre-Build add contents of directory to project

I have the following setup:
Main Website - MVC 3 project, to be hosted on www.domain.com
Intranet Web App - MVC 3 project, windows authentication, hosted on admin.domain.com, which is only accessible from within the local subnet.
CDN Website - A simple web app that merely serves images to both of the above. It will be hosted (publically) on cdn.domain.com, when we go live. I have set up a local project to mock the CDN during development.
I've written a business layer that allows users in the admin panel to upload images, which are then physically saved to the CDN path that's configured (currently on the local machine i.e. C:\Code\SolutionName\CDNProject\images). The main website then uses the same business layer to find and distribute the images via http://cdn.domain.com/images/. http://cdn.domain.com is currently set to http://localhost:55555, while we develop.
Whenever an image is created via the admin panel, it is physically created on disk. Each developer works on his own machine, we we want to be able to check these files in to TFS, for the time being. As you might have guessed, adding files to the file system does not automatically reference them in the project:
I thought there may be some way to reference these images as resources, or set a directory to a "content" directory of sorts... but I can't find anything.
Some developers work remotely via VPN, and do not have access to the local network (only TFS), so a network path is not an acceptable solution.
I thought I might be able to set a pre-build event up, to add all files in a directory to the project?
There is no very easy way to do that. There are a few ways to think about:
1) Write VS adding which adds new files to project (via DTE - starting point). Find out how to automatically run this VS addin on Pre-Build step. Install this addin to your developers machines.
2) Extend your admin logic to automatically check-in the uploaded files to TFS via TFS API
3) try to apply more sofisticated techonologies like this one: T4 Tutorial: Integrating Generated Files in Visual Studio Projects
Hope that helps,
Visual Studio project files have an XML syntax. Project file properties can be modified in a simple text editor (files added/removed, etc.).
You can create a script to open your solution, and before actually opening the solution, you can scan that directory and "inject" the files (with the appropriate XML tags) in the project files.
I don't think you can add this as a pre-build event because the project files are already loaded at that point, and you cannot modify them while they're used.

Azure publish issues - Busy - Restarting - Busy - Cycling

Azure is giving me a headache.
I started off with a tutorial. Created a new MVC 3 project published it. Took about 9 mins then it was working fine on my production VM.
Then I tried to publish a project I've been working on (MVC 3). It has the following dependencies:
Service.dll
Domain.dll
Autofac.dll
It works fine when I debug using the emulator.
It works fine when I unzip the package and deploy it to another server.
But when I publish to Azure Production I get the following:
1:42:31 PM - Preparing deployment for Website with Subscription ID: ...
1:42:31 PM - Connecting...
1:42:35 PM - Verifying storage account '...'...
1:42:38 PM - Uploading Package...
1:44:46 PM - Creating...
1:45:56 PM - Created Deployment ID: ....
1:45:56 PM - Starting...
1:46:34 PM - Initializing...
1:46:34 PM - Instance 0 of role Website is in an unknown state
1:46:34 PM - Instance 1 of role Website is in an unknown state
1:47:06 PM - Instance 0 of role Website is creating the virtual machine
1:47:06 PM - Instance 1 of role Website is creating the virtual machine
1:47:37 PM - Instance 0 of role Website is starting the virtual machine
1:47:37 PM - Instance 1 of role Website is starting the virtual machine
1:50:13 PM - Instance 0 of role Website is in an unknown state
1:50:13 PM - Instance 1 of role Website is in an unknown state
1:50:44 PM - Instance 0 of role Website is busy
1:50:44 PM - Instance 1 of role Website is busy
1:54:31 PM - Instance 1 of role Website is restarting
1:55:02 PM - Instance 1 of role Website is busy
1:56:40 PM - Instance 1 of role Website is cycling
1:57:43 PM - Instance 0 of role Website is cycling
I've tried number of times. With no success.
Update
I forgot to mention that I have the facebook C# sdk DLLs
I've used trial and error to find that the Facebook.Web.Mvc dll is causing me issues.
It has been included inside the bin folder but still no good.
The Azure environment doesn't have all the MVC 3 assemblies. You need to make sure you reference them all in your project and set CopyLocal = true so that the assemblies get included in your Azure package. Azure will go through this infinite cycle if it can't find all the dependencies for your project.
The assemblies you need to reference are:
Microsoft.Web.Infrastructure
System.Web.Helpers
System.Web.MVC
System.Web.Razor
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
One blog I saw also mentioned needing WebMatrix.Data, but I found I did not need this one in my project.
If you have any other assemblies you are referencing that are not part of the .NET Framework, you will also need set CopyLocal = true on those as well.
Also, make sure your Azure storage setting is NOT set to "Use development storage" when you deploy to Azure -- this will cause the same problem.
If the above doesn't solve the problem, check this site for some other possible causes.
As Brian Rogers notes the requirement for asp.net MVC assemblies and points to a good resource for reasons of role being cycling. One Additional thing can help with MVC specifically. You can right click on your Web Application Proejct and select "Add Deployable Dependcies" then select ASP.NET MVC3. This will make sure all MVC3 required assemblies are with your project when depeployed.
Set the reference attribute "copy local" to "true" for each of the references used in the project. This worked for me.
I ran into a similar issue after updating my project to use Azure .NET SDK version 2.0.
The update procedure changed the configuration files but did not update the versions referenced by the projects. I solved this by manually removing the references to the old 1.8.* versions of the DLLs and then adding references to the 2.0. versions.
Please verify any third party dlls which were build for only 32 bit or 64 bit in your solution..these kind of dlls caused to the role cycling and busy..

Resources