I have successfully upgraded to VS/TFS 2017, and I am at the point where I want the build to automatically publish a website to a staging location using one of the project's publish profiles. I am impressed with the flexibility in the "Build & Release" section of the TFS Team Project Site, but it's a little overwhelming.
This project has 2 simple publish profiles. Both use the 'FTP publish method' to upload to the Go Daddy hosting provider; one deletes all files before upload, the other only updates files. There are transforms applied for things like connection strings. These publish profiles work properly. I just need them to be added at the end of an automated build.
It would seem it should be simple to say 'use this publish profile', but there are so many options and choices it's not intuitively obvious which to use, and I haven't been able to find a reference on the web that focuses on what I want to do.
If you want to invoke the msbuild command using the publish profile to publish website to FTP location, then it's impossible as FTP publishing is not supported on the command line.
If you insist on invoking the publish profile, then you can invoke msbuild command line with the publish profile used to publish the website to a staging location (eg, local or UNC path), then use FTP upload task step to upload the website from the staging location to the specific FTP location, or using PowerShell script to upload the website.
You can reference this thread:
How can I add FTP website deployment to a VS2015/TFS2013 build process
Related
When I started writing this question, my problem was that after a successful VSTS Build, I wasn't able to see the files relating to my web application project for release. Only the files from certain other projects in the solution were present. However, I just came across this question, which has helped.
I can now see the compiled .dll files for my web application project, after altering the configuration of the Content setting in the Build - that is, the contents of the Bin folder under that project. But I can't see anywhere the other files I need to copy the built web application to my server - the views, the scripts, the css, etc.
I'm finding the power and flexibility of VSTS's Build and Release functionality very confusing as it's complete overkill for our requirements. Up until now, I've just right-clicked on the web app project in Visual Studio selected Publish and used the File System publish method. Easy. Now that I want to automate the building and deploying of the application, it's many times more complicated!
So, can anybody tell me how I can get the solution to build in VSTS in such a way that I can then use a Copy Files task in the Release Definition to copy the files to our web server (the server isn't visible to the Internet so I'm using a locally-hosted Agent)?
In vNext build, to publish your build artifacts with the Copy files or Publish build artifacts steps. Try to use the local path on the agent where any artifacts are copied to before being pushed to their destination. For example:
Add /p:DeployOnBuild=true
/p:OutDir="$(build.artifactstagingdirectory)\" arguments in Visual
Studio Build step;
Change "Path to Publish" of Publish Build Artifacts task to
$(build.artifactstagingdirectory)\_PublishedWebsites\ProjectName:
Details please check the screenshot of build step with this question: How do I get the the expected output from a TFS 2015 build (to match my XAML build)?
Base on your comments, you have published the web app from Visual Studio. Usually, this action will generate a publish profile under Project/Properties/PublishProfiles folder. The settings you used to publish the web app is stored in the profile. So you just need to make sure this publish profile is checked into source control. And then in the TFS build, add following MSBuild arguments:
/p:DeployOnBuild=true /p:PublishProfile="publishprofile.pubxml"
We have just installed TFS 2015 (Update 1) on-premise and are trying to create a Continuous Integration/Build system using the new TFS Build system. The build works fine, and gives me a green light, but when I look at the default build it has only built the binaries from the bin directory, and there seems to be no easy way to deploy the app on-premise to a local server.
There are two deploy options for a filesystem copy, and a powershell script, and it would certainly be easy enough to use them to copy files to a new server, but since the build only built the binaries, I don't see a tool to gather up the Web artifacts (cshtml, images, scripts, css, etc..) for this.
After an exhaustive google search, I've only found one article which talks about this at:
http://www.deliveron.com/blog/building-websites-team-foundation-build-2015/
However, this uses WebDeploy and creates a rather messy deploy package.
How can I deploy the site (standard MVC web application, in fact my tests are using the default boilerplate site created by the create project wizard) complete with artifacts to a local server in the easiest possible way? I don't want to have to install WebDeploy on the servers, and would rather use PowerShell or something to deploy the final artifacts.
The build is just the standard Visual Studio build template, with 4 steps (Build, Test, Index & Publish, Publish Build Artifacts).
We use "Visual Studio Build" step and as Arguments for MSBuild we use following line:
/p:DeployOnBuild=True /p:PublishProfile=$(DeploymentConfiguration)
On Variables tab page DeploymentConfiguration has to be configured. It must be the Name of the publish Profile (filename of the pubxml file). If the file Name is Build.pubxml the publish profile is Build.
for example:
/p:DeployOnBuild=True /p:PublishProfile=Build
I wanted to add that Ben Day has an excellent write-up that helped us package quickly and then release to multiple environments through Release Manager.
His msbuild arguments look like this:
/p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl=$(build.artifactstagingdirectory)\for-deploy\website
The difference between this and the accepted answer is that this parameter set stages everything in an artifacts folder, and then saves it as part of the build. We can then deploy exactly the same code repeatedly.
We capture the web.env.config files alongside the for-deploy folder and then use xdt transforms in the release process to ensure everything gets updated for whichever environment we're deploying to. It works well for all our web projects.
We use WebDeploy/MSDeploy for 40+ applications and love it. We do install WebDeploy on all our servers so we can deploy more easily but you could also use the Web Deploy On Demand feature which doesn't require WebDeploy be pre-installed.
I'm testing my assumptions at the moment. I have my Asp.Net MVC application located at www.myapp.com/app and a third-party CMS system on www.myapp.com/.
The web-site is set up like described in this answer
At the moment I can publish both of the applications separately and manually from Visual Studio and it works fine.
However, I'm trying to publish my application from a build server where I'm using Azure Power-Shell scriplets:
PS> Publish-AzureWebsiteProject -Name myApp -Package MyWebDeployPackage.zip
However, documentation does not mention if you can publish with this scriplet to a non-root folder.
Any way I can publish an application to ~/app from a command line?
UPD: I can publish from msbuild via
msbuild .\SolutionName.sln /p:DeployOnBuild=true /p:PublishProfile=ProfileName /p:Password=passwordForAzurePublishing /p:AllowUntrustedCertificate=true
Where ProfileName is a web-deploy profile configured to deploy to sub-folder of Azure Web-Site and Password is deployment password from Azure profile.
However this is not an optimal solution: to deploy to test and to production environment, I need to build the application twice, which I'd like to avoid: if I compile views, it takes 7-10 minutes (we have 800 views). Doing this twice is a waste of time.
UPD 2: Created an issue on Azure SDK Tools repository: https://github.com/Azure/azure-sdk-tools/issues/2667
I don't think this is possible from PowerShell, but I might be mistaken. Looking at their publish code here https://github.com/Azure/azure-sdk-tools/blob/master/src/ServiceManagement/Services/Commands.Utilities/Websites/WebsitesClient.cs#L1136-L1168
and also here https://github.com/Azure/azure-sdk-tools/blob/master/src/ServiceManagement/Services/Commands.Utilities/Websites/WebsitesClient.cs#L1218-L1229
they don't have a parameter for the app name, and the code in the second link builds the site name/slot manually.
I would say open an issue here https://github.com/Azure/azure-sdk-tools/issues for this and somebody from the Azure PowerShell team should look at it.
I need to publish a specific folder in my project to my web site using tfs builds. I know tfs copies to a drop folder but I also need it to publish to my web server when I queue a new build. Is there anyway I can do this? I currently have web deploy installed on my server and I have tested it and know it works. Would these be some type of build definition? I can only find sample definitions that copy to a UNC path.
My application consists of a Server and Client. Each of our customers has a PC that will host the server and a clickonce deployment of the client that they can then install on whatever PCs they want to have it. I am currently trying to find out the best way to handle this since the support for publishing clickonce installers from TFS Build seems to be nonexistent.
The publish URL for each customer will be different so I would like to have a separate build for each customer that just reuses the binaries built for the server and client.
My ideal solution would be having a team project for the code (Server and Client) and then a separate team project with folders for each customer. The Customers Team Project would also house the binaries from the builds of the Server and Client. Then I would create a build for each customer that would change the publish url of the client clickonce .application file and re-sign it.
The biggest place I am stuck right now is how to get the clickonce publish files from Team Build, but I am also curious if there is just a totally better way to do this that I have missed.
Thanks
See "Building ClickOnce Applications from the Command Line [MSDN]"
I think you could set up a MSBuild workflow activity in Team Foundation Build to publish each of your customer's projects, if you're using the default Workflow template.