TFS XAML Build Console App - visual-studio

I'm using TFS2017 and VS2015.
I have a solution with multiple WebApps and a ConsoleApp.
When I do a TFS build I get the WebApps built and dropped to the location I need. but so far I have been manually copying the ConsoleApp.
Is there a way for TFS to build the ConsoleApp and also drop it in a specific location?

Why you have to use the Xaml build system? See Why You Should Switch to Build VNext
In TFS 2017 you can easily use the new vNext system to build the ConsoleApp and drop it in a specific location.
You can build the entire solution with VS build task or separately build the ConsoleApp projects with the MSBuild task with the MSBuild Arguments set e.g : /p:OutDir="$(build.artifactstagingdirectory)\\"
Then use the Publish Build Artifacts task to drop it in the specific location.

You can use a PowerShell script as post build script in a xaml build and use it to copy files to the build output. Sample script for XAML builds available here

Related

How to use default project output locations in TFS 2013 build definition?

I have a solution which has several VC++ projects. I am trying to make TFS do weekly builds. I have set up TFS Build controller and agent. I created a build definition using DefaultTemplate.xaml file and I can successfully build some of the projects.
The problem is my projects depend on some libraries that are already checked in to debug/release folders. TFS is trying to put project outputs (dlls and exes) to $(SolutionDir)\Binaries directory. Since dependent libraries don't exist on this location, TFS build fails.
What I would like to do is use my own project output locations and somehow copy the output files to somewhere in server.
How can I do that?
Thanks
It's not recommended checking in the libraries to TFS, you can use Nuget to restore the packages.
For the build outputs, you can specify the drop folder in your build definition and copy the outputs to the drop folder.
You can also check in a script that copy the outputs, 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
I would suggest to edit your build definition. Under Process section, set MSBuild arguments to
/p:GenerateProjectSpecificOutputFolder=true
As follows:

i want to write a TFS post build script to copy Folder and its contents to drop

I want to execute a post-build script from TFS which copies a folder in my TFS to the Build drop location.
I have very little knowledge of how to do this.
Kindly provide with the code.
I am using VS2015, tfs 2015.
i also have VS 2013, TFS 2013
TFS 2015 Build has an out of the box template 'Visual Studio' that already does this using the PublishBuildArtifacts task.
Look at leveraging this task in your build def in order to accomplish what you are looking for.
https://msdn.microsoft.com/en-us/Library/vs/alm/Build/steps/utility/publish-build-artifacts
https://github.com/Microsoft/vso-agent-tasks/tree/master/Tasks/PublishBuildArtifacts
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
In vNext build, you can simply add a PublishBuildArtifacts task as Mr. Kraus mentions. About how to use this task, check: http://www.codewrecks.com/blog/index.php/2015/06/30/manage-artifacts-with-tfs-build-vnext/

trigger build tasks in visual studio and tfs build

I have a c# solution with multiple projects. I have a .sln file I build the solution with in VS2012.
I am looking to set up TFS Build and want to include some custom msbuild actions, such as running stylecop and fxcop rules. I want these tasks to fire when building the solution locally and within tfs build.
I have looked at creating a .proj file for the solution. However, I am not sure how this can be setup locally and to run the tasks locally.
What is the correct setup for tasks to be run within tfs build and visual studio?
My best guess is to set the flag "Enable Code Analysis on Build" in the project settings "Code Analysis". More on that here.
I suppose that running StyleCop is better fitted in the IDE (check R#) or the VCS (check SVNStyleCop) on commit. I am not sure if the same exists for GIT or other repositories.

Integrating MSBuild into Visual Studio

I'm a solo developer running Visual Studio 2008 and looking into MSBuild to improve my build process.
Almost all of the tutorials I've found so far have plenty of information about writing a build file. However I'm having a lot of trouble finding out how to integrate MSBuild into Visual Studio. Maybe MSBuild is only used with something like CruiseControl but that's overkill for me as a single developer.
Where should the build file live in a Visual Studio project and how can I run it from within the IDE?
Visual Studio executes MSBuild automatically for projects it supports.
If you right click on a project and unload it, you can then edit it in Visual Studio. Reload (right click on project again), force a (re)build to test your changes. An alternative is to edit the project file in an external editor and Visual Studio will detect saves and offer to reload the project for you.
Sounds like you're on the right track, and if you are considering writing Targets or custom MSBuild Tasks, take the time to separate them from your current project so that you can re-use them. Don't re-invent the wheel though, the two main complementary MSBuild projects are MSBuild Community Tasks and MSBuild Extension Pack.
Update: Judging from your comment on Mitch's answer, you might also want to consider adding a new Configuration element or custom properties to a project. A new MSBuild Configuration (something other than the default Debug/Release) could run unit tests, build documentation, or whatever you want automated. A custom MSBuild property would allow you to use normal Debug/Release Configuration and extend it to automate more of your build process, just depends on what you want. Either approach could also be driven from the command line.
As others have noted, MSBuild is already available when you install Visual Studio.
If you want to integrate into VS2008: Running MSBuild from Visual Studio
MSBuild is the build engine used by Visual Studio to process the files included in a project.The Visual Studio project files themselves (**.csproj* for C#, and .vbproj for VB, for example) are in fact MSBuild scripts that are run every time you build a project.
Your .csproj file is a MSBuild file. So you are actually using it already.
You may of course wish to create a separate build file to have more control, especially within a continuous integration or nightly build say.
If you simply wish to edit your project build file then you can use the IDE to edit some settings such as pre and post build actions or edit the Xml itself by unloading project and right click and editing.
You can use your current .vcproj files to build your project with MSBuild. However, as MSBuild is not directly supported (at least for vc++) vcbuild is used instead (internally).
In VS2010 all project files are MSBuild based...
This is an older article about some simple extension points from the msbuild team
How To: Insert Custom Process at Specific Points During Build
Also, don't forget you can use the MSBuild SideKick for developing and debugging your (local) msbuilds, available for free at http://www.attrice.info/msbuild/
I'd suggest you call msbuild as a post build step. Then you can put your build script somewhere in your solution and call it.
<windowsdir>\Microsoft.NET\Framework\v3.5\MSBuild.exe c:\temp\MyProject\mybuildfile.proj
The easiest way is probably to invoke your custom build script using a post-build step. Right click project, choose "Build Events" and call msbuild with your custom msbuild file from there.
I use the msbuild template to intergrate with visual studio
http://msbuildtemplate.codeplex.com/

How can we generate the build file from VS.NET

If i have a VS.NET 2008 solution , and i want to export the build script so that i can use it to build the same application in another environment which does not have VS.NET, how can i extract this make or build script from the VS.NET ?
Thanks.
If your solution consists of .csproj or .vbproj, it is already a build script with MSBuild as the build engine. MSBuild comes with .NET framework, not with Visual Studio.
Edit:
You can launch MSBuild from the following locations:
%windir%\Microsoft.NET\Framework\v2.0.50727
%windir%\Microsoft.NET\Framework\v3.5
%windir%\Microsoft.NET\Framework\v4.0.xxx
Starting with version 3.5 of the tool, you can specify the target framework for which you want to build by specifying the "ToolsVersion" attribute on the project element.

Resources