TFS Build - How to deploy to Multiple locations - visual-studio-2010

How to deploy (copy the application files) to multiple locations when TFS build is executed.
See the picture when ever build is initiated I am copying to a location, I wanted to give multiple location in MSBuild Arguments.
MSBuild Arguments : /p:DeployPath=\\ServerName\C$\Inetpub\wwwroot\ApplicationName

Add another CopyDirectory activity to your build process template XAML.
<mtbwa:CopyDirectory DisplayName="Drop Files to Drop Location" Source="[BinariesDirectory]" Destination="[DropLocation]" />
Or, use MSBuild Copy task in the last scipt being run in the build (AKA post-build script).

Related

Running post deployment script after Web Deploy

I have the following problem and I'm surprised that I can't find any straightforward solution on SO or MSDN.
I have existing *.pubxml profiles in several of my web applications and I would like to execute post deployment script - powershell script - which reorganizes WebSite and its child applications slightly.
I'm not usign Web Deployment Package - just Web Deploy.
The script is deployed successfully but the problem is - how should I execute it automatically after deployment?
I have two scenarios:
Execute by simply "Publish..." from Visual Studio.
Execute as part of TFS Build definition (TFS 2013).
You can try to define a “Target” by MSBuild to achieve your requirement.
For the first scenario:
The Visual Studio build process is defined by a series of MSBuild .targets files that are imported into your project file. One of these imported files, Microsoft.Common.targets. This file contains a set of predefined empty targets that are called before and after some of the major targets in the build process.
So you can define a "Target" element whose "AfterTarget" attribute's value is set to "MSDeployPublish":
<Target Name="CustomPostPublishActions" AfterTargets="MSDeployPublish" >
<Exec Command="..\PostDeploymentScript.sp1 " />
</Target>
For the second scenario:
You can add a PowerShell build task as MrHinsh`s suggestion.
You should switch to deploying from Build & Release only in VSTS/TFS.
You can then add a PowerShell build task and either point at a script or use Inline if it's short. If it is a script that you use in many builds you might want to write your own build task.

Continuous Integration on VSTS - Build Definition: No Files - System.AggregateException

I am using Visual Studio Team Services. I created a Simple ASP.NET website and created my Build definition which contains default settings.
After committing changes, the build is triggered using CI. The "Build Solution" Step works fine, however no files are found in the Copy Files Step:
I have created the same build definition for a simple console app, and the build and release are working.
When Creating a release from this build, it fails to deploy (i guess because no files are found in (Build process)) and gives the following error:
When you build Asp.Net project with a default VSBuild definition, the folder bin\$(BuildConfiguration)\ does not exist. So "Copy Files" task cannot find any files with the default settings. A simple way to fix your issue is add /p:outdir=$(build.artifactstagingdirectory) in "MSBuild Arguments" for VSBuild task as following:
And you can also remove "Copy Files" task since "Publish Build Artifacts" task publishes the files in $(build.artifactstagingdirectory) folder by default and you have set the build output to that folder with the argument added in VSBuild task.
Update:
You can add a "Copy Files" task with the following settings to copy "roslyn" folder to "bin" folder:

VSO Copy website static files and binaries (not C# files)

I am trying to set up continuous integration on my server using Visual Studio online.
Created a new agent pool.
Installed and configured a new build agent that I added to that agent pool.
Then I trigger a new build of my code to be handled in my agent pool.
I manage to build it but how to set up the task "Copy and publish build artifacts".
My goal here is to just copy the final website files e.g. binaries, images, cshtml, but NOT all files such c# files. Well sort of like the "Right-click > publish" operation in visual studio.
What value do I need to enter in "Copy root" field? (please see image below)
The documentation is located at: https://msdn.microsoft.com/en-us/Library/vs/alm/Build/scripts/variables
It all boils down to what the output path for your binaries is. If you're not overriding it via an MSBuild argument, $(Build.SourcesDirectory) with a value of **\bin\* will probably get you what you're after.
For a web application, make sure you're building with appropriate MSbuild arguments (something along the lines of /p:OutDir=$(build.stagingDirectory) /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true should do the trick). This will get you a _PublishedWebsites folder in $(Build.StagingDirectory).
Then all you need to do is publish Copy Root of $(Build.StagingDirectory) and Contents of **\_PublishedWebsites\*
Keep in mind that Publish Build Artifacts means publish build artifacts to VSTS or a file share, not deploy build artifacts to a web server

How to tell Visual Studio or to pickup a file and deploy it to the bin directory after build?

I do have few config files and dll files that are needed in order to run the final product and I want to instruct visual studio build to pick them up.
So far it was easy to add them to the project but I wasn't able to identify the correct mix of properties that I need to setup for these files, in order to get the files inside the bin directory (target).
Note: the term deploy here doed not refer to the after build deployment, that would be a custom task anyway.
So far I see these options:
Excluded from Build: No
Content: Yes
Item Type: contains a list of ~20 options but none of them sounds like something that would work. I already tried most of them.
Select the project that requires the configuration file and right click on it and then select Properties.
Go to the Build Events tab and type in the Post-Build event command line something like the following
copy pathfiletocopy $(ProjectDir)$(OutDir)
now you could check the Copy Only on Successful Build option.
Of course you need to adapt the command line to your liking.
You can also press the button Edit Post-build and see a list of predefined macros that refers to specific informations related to your projects and solution. You could also insert other CMD shell commands like IF $(ConfigurationName) == "Release" to execute commands only when you compile for release instead of debug (for example running an obfuscator)

Publish web application from MSBuild Script using VS2010 targets resets working directory

I am trying to automatically publish and deploy my .Net 4 web application automatically from a build script to be run by our continuous integration server. I am using the new _WPPCopyWebApplication target from VS2010 to perform the publish, however it appears to reset the current working directory of the msbuild project to c:\ this causes my prebuild steps to fail as they have relative paths to some external tools. The task I am running from our master.build file is as follows:
<Target Name="PublishWeb">
<MSBuild
Projects="$(ProjectPath)"
Targets="ResolveReferences;_WPPCopyWebApplication"
Properties="WebProjectOutputDir=$(DeployPath);OutDir=$(TempOutputFolder)$(WebOutputFolder)\;OutputPath=$(ProjectPath)\bin\Debug;" />
</Target>
This does not happen when using the legacy _CopyWebApplication. Does anyone have any idea how to resolve this problem?
Two possibilities come to mind:
Use the Exec task to call msbuild.exe, and supply a specific working directory.
Your pre-build steps are evaluated by MSBuild and can reference any MSBuild property, so make your paths relative to something specific, like $(MSBuildProjectDirectory), or $(MSBuildThisFileDirectory), instead of just relative to the current directory.

Resources