How to publish binaries and copy to server in TFS 2017 - tfs

We were using xaml builds earlier now we migrated to TFS2017. I am not able to publish the build files and how can we copy them.
My Build runs file it does not publish files. I see only the code files.

You need to add Copy Files task and Publish Build Artifacts task in your build definition, to copy and publish files:

Maybe you may create the publish profile for you web project and use it in build process. I use this way for the web site project:
Create the publish profile for project to package: https://msdn.microsoft.com/en-us/library/dd465323(v=vs.110).aspx
Add publish args for the build step. In my case:
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\Test" /p:PublishProfile="shdemowebtest - Web Deploy"
Then copy drop artifact
In your case you may create profile to publish on the file system. Then add build args to publish and redirect the destination folder: MsBuild publish website without using publish profile
Steps for publish to local folder (on VSTS and local build agent):
Add new profile to your project (destination bin\release\PublishOutput):
I use first build step to build additional project with tests.
Add step to publish with default folder path.
MS Build Args:
/p:DeployOnBuild=true /p:PublishProfile="FolderProfile"
3.1. Then I use standard step to copy results to staged directory:
3.2. And publish to drop artifact:
3.3. Then you can use that artifact to deploy with release management:
Add step to publish to custom path:
MS Build Args:
/p:DeployOnBuild=true /p:PublishProfile="FolderProfile" /p:publishUrl="C:\temp\Output"
4.1. The result of this step:

Related

TFS Build: How to get EXE file deployed to website

I have a TFS Build Definition that builds/deploys a web project to our internal IIS server. That works fine. However, I would also like to build/deploy a WinForms app (.exe) to the same web site.
I did add the WinForms solution to the Build Definition. TFS builds the .exe and copies it to the drops folder. But it's not in the _PublishedWebsites folder.
I've been manually copying the file over to the web site. Is there a way to automate this?
Thanks in advance!
In XAML build, you can check in your script, and specify a post-build script path in your XAML build definition. This script gathers some of the typical binary types from the typical locations and copies them to the folder from which TFBuild copies and drops to your staging location. Check more information about Run a script in your XAML build process at website: https://msdn.microsoft.com/library/dn376353%28v=vs.120%29.aspx
If you upgrade to TFS 2015, in the new build system, you can simply add a PublishBuildArtifacts task in your build definition. About how to use this task, check: https://www.visualstudio.com/en-us/docs/build/steps/utility/publish-build-artifacts

VSTS Build Not Dropping All Files for Web Application

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"

TFS2015 VNext build output folders

New to TFS but have managed to set up a vNext build definition and am able to trigger a build that executes successfully.
The build output is placed at
D:\TestAgent_work\c312e966
on the build server. However after every subsequent builds this directory is overwritten with the new build output.
Is there a way of retaining previous builds that include the build version in the folder structure?
Thanks in advance
Use the "Publish Build Artifacts" task to copy the output to either a UNC share or upload it to the server.

How to enable Artifacts link

I have a TFS2015 build definition: after the build step I have a PowerShell step which is publishing the build artifacts.
How can I enabled the Artifacts link in the build summary?
I've noticed that the Artifacts link is visible only when I have a Publish Artifacts build step in the build definition. I can't use this step because I need a specific folders structure in the build drop folder.
The easiest thing might be to use your PowerShell script to prepare your drop as normal but then add the Publish Build Artifacts task so that the artifacts tab of the release is populated.
The example in this article uses $(build.stagingDirectory) to order the files and then specifies that directory in the Copy Root field of the Publish task.
http://www.codewrecks.com/blog/index.php/2015/06/30/manage-artifacts-with-tfs-build-vnext/

Publish generated NuGet Packages with TFS 2015 RC

I am trying to set up an automatic build.vnext process for TFS 2015. This build process contains one Visual Studio Build build step, in which a .nupkg package file is created in the build agent's bin/Debug and bin/Release directories.
I have a private NuGet-Server installed on the same server as the build agents are running on. I want to copy the generated .nupkg files from the bin-directories to my NuGet-Server's package-source-folder (say C:\Packages).
How can I do this with TFS 2015 Build.Vnext/Preview?
Edit:
I can easily copy all build output from the agents to the package folder by configuring the Visual Studio Build options "Copy to Staging Folder" Search Pattern to **/bin/*. This copies the folders myProject\bin\Debug and myProject\bin\Release folders and their contents to the package folder.
If I specify e.g. **/bin/**/*.nupkg or similar, nothing is copied, even though a respective *.nupkg file exists.
I found a solution to this problem:
Under Options set Copy to Staging Folder of the Visual Studio
Build-Configuration to true.
Use the search pattern **\bin*
Add a Command Line utility definition.
Let it execute C:\YourPathTo\nuget.exe with the arguments push C:\YourStagingPath**\bin***.nupkg -s [YourServer] [YourAPIKey]
Done.

Resources