The default behavior of TFS Build Server is copy all output, dlls, exes to the folder C:\Builds\{Build_Agent_Number}\{Team_Project_Name}\{Build_Controller_Name}\Binaries. I have customized the build process, not to copy to that folder but instead copy it to another, let say C:\Builds\{Build_Agent_Number}\{Team_Project_Name}\{Build_Controller_Name}\Sources\Some_Folder\Some_Sub_Folder.
The build process works as expected but the problem is all tests don't run. I debugged the build process template and found that it could not find test dlls. I want to know how can I specify the test dll location in the testsettings file or in the build process template.
You can set it on Find Test Assemblies activity in you Build Process Template workflow. It locates a little below the middle of the process.
Navigate to Find Test Assemblies activity inside Run MSTest for Test Assemblies.
Pree F4 to bring up the properties windows then change MatchPattern to the root path that contains assemblies you want to test. For example, String.Format("{0}\{1}", MyCustomAssembliesPath, testAssembly.AssemblyFileSpec)
Related
I want to use macros of current csproj such as ${TargetPath} $(TargetName),in vNext Build defination as part of vs build task property of MSBuild argument,to do some copy etc.
But I found it not work,in build log, the macros did not be change into the absolute path.
Is there any way to use these macros just like in csproj post-build event?I did not find description about this on msdn ,and I could not use it in each csproj,because we have more than one thousand project files, edit the prj file one by one is not good:(
Thanks alot for your help.
Update
I want each project only output its own assembly without any referenced assembly when build.But I can't change project file to modify the reference property "copy local" to false.
You just need to add it as MSBuild arguments:
If you mean you want to achieve the function in post-build event same as this question Visual Studio Post Build Event - Copy to Relative Directory Location. There is no such thing like post-build in vnext build.
You can add several steps to copy the assemblies (One step for one project) and specify the copy root in the step.Refer to this question Copy one file in target directory on deploy from visual studio team services
However, as you have mentioned there are thousand project files. You can create a powershell script and add it in the build definition to copy the files.
I have a CodedUI test suite. I'm attempting to use a B-D-T workflow in TFS 2015 R2 to deploy the test .dlls to a machine group and execute them.
The tests rely on a couple files - an html start page and an XML file.
First, I attempted to have the tests just run from the bin folder OR where they're deployed onto the machines in the machine group. No suggestions I found on SO or on the first 3 pages of google worked. Whenever I ran a test locally it would copy the test dlls to the TestResults folder and execute from there.
Then, I attempted to use a .testsettings file to deploy the files with the .dlls into the TestResults folder. I still truly don't understand why this is the best or only solution - if I can just execute from the Bin please let me know how, but it does work - locally.
Now in TFS 2015 when I deploy my testing software to the test agent(Member of the machine group), I can see my supporting files exactly where they should be in the test drop location. Then, the test starts. A temp folder is created in a byzantine region of AppData, where only the .dlls and config are copied - not the files specified in the .testsettings file! The testsettings file is specified in the "Run Functional Tests" task, which I reached by browsing to the correct file in source control.
I can provide any information you require. This should be so simple but it has been an enormous headache.
In the configuration you need to setup where you copied the files to on the remote machine using a "Windows Machine File Copy" task executed by the agent. You need to make sure all the files needed to run are copied to the server.
Then in your .testsettings file specify which of the files you copied over you want to deploy to the temporary test context directory. Only files already copied to the test agent can be selected here.
The File copy task would look something like:
In TFS2013 I'm having the following dilemma, a build has always been dropped to a custom folder defined in the Build Definition. Suddenly, it is now needed to have it available online, so the "Copy build output to server" is the logic option.
However, I can't lose the "normal config", so I was wondering if it was a way to execute both Staging Locations. Tried with the .proj configuration file but I can't see a way to do it.
Any suggestions?
Thanks!
You can add a CopyDirectory activity in XAML build process template, or you can program a script to copy the outputs to a custom location in pre-build/post-build.
http://geekswithblogs.net/jakob/archive/2010/09/01/tfs-team-build-2010-how-to-place-the-build-output.aspx
https://msdn.microsoft.com/en-us/library/dn376353.aspx
I seem to be getting a lot of pain with the processing of app.config and token files (we have this working with the older ".11" templates).
It looks like currently (using the ReleaseTfvcTemplate.12.xaml) this is running the tokenisation after the build.
While I can make the app.config / myapp.exe.config stuff work by deliberately copying the .token file into my output folder (so the recursive search finds it) this feels pretty horrid.
As a fix I'm tempted to move lines 182-230 to just before the RunMSBuild task on line 175 (creating a new sequence at that point)
Is this the correct approach or have I missed some documentation somewhere (or a later version of the template?)
Thanks guys... Anyway for future reference I did make the change.
However I had misunderstood the exact nature of the order things happen out of the box which is as follows:
Get the project out of source control
build with msbuild
Copy the .config.token file over the .config file. This is in the TFS template
As part of the deploy to a server then the token entries in the .config files are replaced. This is in the release manager template.
Tests are run in the msbuild binary output folders.
The problem is this doesn't really work if you're using an project type that uses app.config file as the msbuild process renames these output.exe.config during the msbuild stage so you need to create both an output.exe.config (marked as copy to output) and an output.exe.config.token so when the post deploy is the final output gets configured correctly. This also a problem if you want to tokenise some mstest dlls as these typically use an app.config as well. Basically this is a bit of a mess unless you are using web.config.
We worked our way around this by using the modification I suggested above (you need to create a sequence at line 175 and move lines 178-230 up into the sequence, this is GetBuildDirectory variable bits and the if statement) followed by adding an additional deployment stage which copies back onto the build server with the new tokenised files so the mstest can run against them.
So our new process looks like this:
Get the project out of source control
Copy the .config.token file over the .config file i.e app.config.token copied over app.config
build with msbuild (this means we end up with tokenised myapp.exe.config and mytests.dll.config)
As part of the deploy to a server then the token entries in the .config files are replaced. This is a release management step in the release template.
Deploy the tests back into a folder on build server (think this has to be a fixed folder until update 4 of release manager is deployed) the token entries in the .config files are replaced (so our integration tests can use the newly deployed servers). This is a release management step in the release template.
Tests are run in the fixed folder on the build server (rather than the msbuild output directory) so the test wildcard needs to be changed in the tfs build template.
Quick final note we don't use that build directory variable and it's left at blank I'm not convinced this would work if it was set to a value...
The replacement of variables in config files with Release Management happens at deployment time and not at compile time.
When RM deployes your app it inserts the correct variables.
It sounds like you're hitting one of two issues:
You need to include the .token file in your project and make sure it's set to Copy Always, so that it gets copied to the build output folder.
If you're building a web application, I've seen a bug in the release build process template that doesn't touch the contents of the _PublishedWebsites folder. I don't know if it's been fixed in Update 4 or not, but it was definitely still a problem in earlier versions.
I’m using a few custom MSBuild tasks that are checked into source control. I would like to import these tasks into my TFSBuild.proj file that TFS uses to build the project. Right now I have created a 2nd project file that includes all of the uses of these custom tasks. I do this because I can run this project file after the workspace has been created and the files have been downloaded.
Is there a way to reference the files on the server from the build project so that I don’t have to do this 2 step process?
I wish the following would work.
<Import Project="$/My/Server/Path/Custom.tasks.targets" />
This question is related to another question. In my case the tasks are checked into source control so that the build machines don't have another required install. Placing the tasks locally doesn't work very well in this case.
If you put the tasks and the .targets file(s) in the same version control folder as your TFSBuild.proj file (or in a sub-directory beneath it), TFS Build will download all of that content to your build agent prior to kicking off your build script.