TFS 2013 build - Files copied using Post Build Event are not found - tfs

This is a winform application.
All dlls, exe and some other extension files are copied to the StartupProject\bin through the post build events(VS post-build).
On TFS Server, the project has 2 subfolders: bin and src.(bin contains required dlls, but other extensions are missing -.png, .dat, .xslx).
On the server, the post build copied files appear under the StartupProject\bin, but they are not copied to TFSFolder\bin.
How can I force copy all the StartupProj/bin to the TFSFolder\bin?

Team Build use a different directory layouts from Visual Studio builds. All Binaries go in a single folder for any project built, so references are automatically solved and it is easy to copy the DLL to the final Drop folder.
You should use $(OutDir) MSBuild variable to properly reference the binaries directory in VS and TFS builds. See Is there a single MSBuild and TFSBuild variable that will point to where the binaries are? for some details.
If you need to use different scripts for desktop (VS) and server (TFS) builds, use the $(BuildingInsideVisualStudio) variable as explained in TFS 2010 Build Automation and post-build event.

Related

Why isn't MSBuild with TFS 2017 copying content items in to the $(Build.BinariesDirectory) directory?

I have upgraded my company's TFS from 2013 to 2017. We still have our old XAML build definitions but are moving to the new JSON templates.
Most of the build definitions are working fine but some don't act like the former XAML definitions. I get all of the compiled assemblies in the $(Build.BinariesDirectory) folder but if I have a csproj that has Content items set to CopyAlways, they get copied to $(Build.SourcesDirectory), but they do not get copied into the $(Build.BinariesDirectory) for MSBuild. Project set up in Visual Studio
When building the old XAML build definitions they are copied to the bin directory fine: Build agent with the copied content
I have tried changing versions from 15 to the older 14 which still did not resolve this situation.
If you mean using the vNext build system, then you can add below msbuild arguments in the MSBuild Arguments area of the Visual Studio Build or MsBuild task to get the target files copied to the binaries directory.:
/p:OutputPath=$(Build.BinariesDirectory)
Note: The output is going to the \b\ folder, as the value of the variable $(Build.BinariesDirectory) is something like c:\agent\_work\1\b.
Build.BinariesDirectory :
The local path on the agent you can use as an output folder for
compiled binaries. For example: c:\agent\_work\1\b.
Source: Predefined variables

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.

tfs agent build required files

How can I set tfs build on agent to use one location for following files?
I have couple files that are run on after build of specific project.
files:
SomeFile.exe
RequiredDll.exe
I am using it for creating custom setups files, that is done from SomeFile.exe.
Now every time I have project that I want to run the actions, I need to copy files above into the project, which I know is wrong.
Is there any other way?
You can put these files in a common location within Source Control. Then in your build configuration you can map that common folder to a working folder for the build.
This is named slightly differently in the different versions of Visual Studio. In all versions it is found when editing a build configuration.
Visual Studio 2008 / 2010
Workspace
Visual Studio 2012
Source Settings
This allows you to map a source control folder to the Build Agents working build folder. You will then be able to access the same exe's in all your builds and they will only be in Source Control once.
A common practice is to have a Team Project dedicated to build artifacts. Then in your mappings you have something like this:
StatusSource Control FolderBuild Agent Folder
Active$/BuildProject/lib $(SourceDir)\BuildArtifacts

TFSBuild 2010 Package only contains sources - not binaries

The packages created by a TFS 2010 Build only contain our Sources, not the binaries. When this is (automatically) deployed to IIS, the site does not run because it is missing DLLs that are created during the build process.
We have a Web Project created in VS2010. If I select "Build Deployment Package" from a right click in VS we get a zip file in the obj\Release\Package folder that contains the fully build site.
However, if ask our TFS build process to create the package by adding "/p:CreatePackageOnPublish=true /p:DeployOnBuild=true" to the MSBuild arguments (as advised in amongst other places here) we get an zip file in _PublishedWebsites\_Package\.zip that only contains the sources.
My best guess is that the CopyAllFilesToSingleFolderForPackage is picking up the files from the wrong place.
I notice a similar issue asked here - TFS 2010 and creating a package - although his workaround in not appropriate in many cases, I'd guess.
My concern is that this is using a built-in, but poorly documented feature of MSBuild/TFS so when it doesn't work you're a little in the wilderness.
It seems that deployOnBuild runs some "package"-like target on each of the projects. If you have built the projects into a separate directory (which the default TFS 2010 build does by default) the packaging won't pick up the compiled files.
One solution is to get rid of the custom output folder for the MSBuild Command within the TFS build workflow. This will cause the compiled files to be located in-situ and be included in the package.
Now the rest of the TFS workflow is require some changes because it'll be expecting to transfer the files from the output directory, and they won't be there.

msbuild and updating files in tfs

I need some help to create a msbuild script.
We are using TeamCity 5.1.2, VS2010 (.net 4.0) and TFS in our environment. We have a "SharedLib" folder in tfs where we put those dll's that are used by multiple projects.
What we do is that we have a database project that handles db access and when we build that, a post build event copies the output dll to the SharedLib folder. Our "client" projects reference that dll from the SharedLib folder.
What I want to do is that when I check in files from the database project into tfs, the build is started in teamcity. If the build is successfull, I want to check out the database dll from the SharedLib folder in tfs, update the file with the new version and check in that file to tfs again.
How can I write a msbuild script that does that for me?
You can use the <EXEC $(TF) checkin ... /> command for that.
See http://blogs.msdn.com/b/nikhilsi/archive/2008/06/12/how-to-autoincrement-version-with-each-build-using-team-foundation-server-build-with-a-little-help-from-assemblyinfotask.aspx how you can use it.

Resources