How to keep the subfolder in DropLocation constant in TFS build - tfs

I have a build definition setup with a drop location. The binaries are moved into this location, but under a new directory (named as build number) every time. Is there a way to have the same location over written everytime. we have some batch files that copy the binaries out to multiple servers that will be accessed by the end users. We need the location to remain constant so that the batch files can work correctly.
If this is not possible, is there a way for the batch files to pick the latest location which contains our exe (sometimes, the folder is created even when the build failed).

Having an unique name of the drop location, is something you cannot (and don't want to) change. To solve your issue, you can either
1) start the batch files with arguments (so the directory is %1) where you specify the name of the directory
2) Add a task in the build to copy all the files to a file share. If you are using TFS 2008, you can follow the steps provided at http://blogs.msdn.com/b/msbuild/archive/2005/11/07/490068.aspx to copy the files.

If you are using TFS 2005/2008, then TFS Deployer. It flat rocks when doing deployments.
TFS 2010 has a new build deployment model that is pretty good.

Related

TFS 2018 MSBUILD Download files task equivalent?

We are moving to TFS 2018 from 2012 and I'm working on migrating the builds. One of the builds has a few mtbwa:DownloadFiles activities in it but I don't see an equivalent way to do this in the new build system. We have a few utilities in a different branch that are used to build installers. So I need to download those utils before completing the build. How would I do this in the new build system?
If the files are in source control, then you can map the source directly in Get source step.
Then the files will be automatically downloaded to the $(build.sourcesDirectory) by deafult on the agent machine.
After that you can also add a Copy Files task to copy the files to any location as needed.
If the files are not in source control, you can also use the Copy Files task to copy them, but you need to make sure that the service account has the proper permission to access the source folder.
UPDATE:
If the team projects are in same collection, map sources in Get Sources step is also available. You need to manually specify the Server path (Click ... can only navigate to the root path of current team project).
e.g.:
In below screenshot I entered the server path $/2017ScrumProjectFromVS/WpfTest
This also works with the Copy Task, that means you can copy the files directly from another team project which in the same collection.

TFS programatically find and use files from last build

I am new to TFS. I have two builds on TFS, one is the main solution which spills out .exe files, the other a Wix installer solution that grabs files from the main solution. Right now I use a temp file folder and post/pre build events to receive/feed these .exe files.
Can I streamline this process on TFS? I'd like the installer to
Main solution generates a meaningful file path for each build, ideally related to build number.
Installer solution can find file path of the last successful build of main solution programmatically.
Make this file path available as a build variable or something so it knows where to grab files when building.

Can we create TFS build definition of website without .proj file

I am using TFS 2015 for creating builds of application. I am able to create build template for web application as web application have both .sln and .proj.
But for Websites, I only have .sln file and no .proj.
How can I create Build definition in TFS 2015 for website having only .sln file?
As #Cece said, the answer is yes, you can run the MSBuild on the server without a .csproj.
I am assuming that your project is not running on the final version of the .Net Framework. In your case I suggest you to make this change
https://stackoverflow.com/a/42493822/819153
Then you should copy all the files from the PrecompiledWeb folder, and there you should find your .sln
Sometimes there are vb/cs projects that I have seen that they do not come with a project file, csproj or vbproject. They run with the .NET Framework 2.0. For those, you can create a build definition just to compile the .sln, but when you deploy the application, you need to copy the entire PrecompiledWeb folder to the IIS folder on your server. Try to add the task that has the option copy and publish and put all the changes to your server.
Check the privilege of the folder where you want to put the files, and be sure that the agent that is running the builds on the TFS has access READ/WRITE access to the server folder.
In your case, please check the .sln file, inside of it you should have a TargetPath, by default is PrecompiledWeb, but sometimes when you run the msbuild on the tfs you end with an error saying that the PrecompiledWeb can't be on the same tree of your solution, what you need to do then is putting a level up of your solution folder
Debug.AspNetCompiler.TargetPath = "..\..\PrecompiledWeb\YourProject"
Then on your CopyTask you need to change the CopyRoot directory, if you made any transformation before your build step to the webconfig, those transformations will be reflected on the PrecomiledWeb\YourProject. All the files in that folder should be deployed to the server folder path.
Lets say that you have this structure in your Branch
Branch/MyProject, then after you compile the source code on the TFS, your precompiled folder will be stored at the same level of your project on the agents folder. Please see the picture below to get the idea how to copy the files from the PrecompiledWeb.
The answer is Yes. You can create a build definition for a WebSite project by specifying the .sln file.

TFS build modifying website folder structure

In my solution I have a basic ASP.NET MVC website and a Wix Project. To identify the files that need installed I'm using Heat (a Wix component) to index the build output. This is part of a post-build event. It works perfectly on my local machine when building in Visual Studio 2015.
My problem occurs when checked-in and the CI (TFS Build) builds it. The differences are:
The contents of the bin folder is placed directly in the build folder
The rest of the website is placed under a new _PublishedWebsites folder
This means many of the references get broken. For example when dropping the _PublishedWebsites folder into IIS breaks (as .net cannot locate the contents of Bin)
After much research on the subject, and many attempts to pass MSBuild parameters, I'm reaching the end of my efforts.
Is there a way for a build in TFS to leave file locations intact without copying and creating new folders?
If not what is the recommended way to get a deployment ready site (in a single folder) from TFS?
Adding a Copy Files task to copy bin folder to $(build.artifactstagingdirectory)\_PublishedWebsites, check the screenshot below:

TFS Build - Copy Changed External Files

We are new to TFS (2013 Update 4) and are trying to implement a build process. Part of the deployment process involves finding a series of external files (namely .sql files) and copying them to a separate folder for the DBA to deploy.
At this time, and for the foreseeable future, this process cannot change. However, to make things easier, is there a way to have the build definition copy all of the files (from a specific folder tree) that are marked as changed in the associated changeset(s)?

Resources