How to prevent TFS from moving vstest.console runsettings file - tfs

I'm testing an upgrade from TFS2015 to TFS2017 and ran into a problem when running my unit tests.
The test needs a runsettings file:
The runsettings file is physically at C:\TFS\1\s but for some reason TFS2017 is copying it to C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\tmpA03 as can be seen in the log:
2017-02-01T21:04:44.9728814Z Working folder: C:\TFS\1\s
2017-02-01T21:04:44.9728814Z Executing C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe "C:\TFS\1\s\SpecFlow2\bin\Debug\SpecFlowTests.dll" "C:\TFS\1\s\UnitTests\bin\Debug\UnitTests.dll" "C:\TFS\1\s\UnitTests-Analytics\bin\Debug\UnitTests-Analytics.dll" /TestCaseFilter:"TestCategory!=MultiThreadedTests&TestCategory!=Purgatory" /Settings:"C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\tmpA03.tmp" /logger:trx
My runsettings however, contains a reference to a testsettings:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<!-- 0 = As many processes as possible, limited by number of cores on machine, 1 = Sequential (1 process), 2-> Given number of processes up to limit by number of cores on machine-->
<ResultsDirectory>.\TestResults</ResultsDirectory>
<MaxCpuCount>3</MaxCpuCount>
<TargetPlatform>x64</TargetPlatform>
</RunConfiguration>
<MSTest>
<SettingsFile>SingleThreaded.testsettings</SettingsFile>
<ForcedLegacyMode>true</ForcedLegacyMode>
</MSTest>
</RunSettings>
Because SingleThreaded.testsettings remains in C:\TFS\1\s, the test run fails, and even if I manually copy the file, the test still fails because some of the tests relied on the test's working directory.
How can I prevent TFS from moving my runsettings file to the temp folder and execute from the correct directory?

I couldn't reproduce your issue on my side in TFS 2017 with the setting below:
In the log, the runsetting file is gotten from C:\Agent\_work\10\s\Parallel.runsettings, so TFS won't move the setting file automatically:
2017-02-03T06:08:37.8352139Z Working folder: C:\Agent\_work\10\s
2017-02-03T06:08:37.8352139Z Executing C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe "C:\Agent\_work\10\s\ClassLibrary1\bin\Release\Microsoft.TeamFoundation.TestManagement.Client.dll" "C:\Agent\_work\10\s\TestCaseProject\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll" "C:\Agent\_work\10\s\TestCaseProject\bin\Release\Microsoft.TeamFoundation.TestManagement.Client.dll" "C:\Agent\_work\10\s\TestCaseProject\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll" "C:\Agent\_work\10\s\UnitTestProject1\bin\Release\Microsoft.TeamFoundation.TestManagement.Client.dll" "C:\Agent\_work\10\s\UnitTestProject1\bin\Release\UnitTestProject1.dll" /Settings:"C:\Agent\_work\10\s\Parallel.runsettings" /logger:trx
Please check whether you have mapped the runsetting file in Repository tab of the build definition. And try to clean the cache file on your build agent: C:\Users\username\AppData\Local\Microsoft\Team Foundation\7.0\Cache.
If issue persists, try to deploy a new build agent to see how it works.

Related

Integration of tSQLt + SSDT into Jenkins

I am using SQL Server 2017 and Visual Studio 2019 Community edition.
I have created my first SSDT project and configured it in Jenkins and I am facing issues while deploying it before running my tSQLt test cases.
Please refer to the link which I used to configure everything:
https://the.agilesql.club/2017/03/sql-server-continuous-deployment-in-a-box/#comment-4976546606
PS: Have made changes in related ps files for paths of msbuild and other related files as I am using SSDT and Sql server recent versions and above link shows older versions.
Error
I got succeed to build my ssdt project in jenkins but when it tries to run "DeployDacpac.ps1" in "Unit Tests" step it shows success in pipeline steps but actually script shows error like :
C:\Program Files (x86)\Jenkins\workspace\Test12_master>powershell.exe -ExecutionPolicy RemoteSigned -File "C:\Program Files (x86)\Jenkins\workspace\Test12_master/Deploy/DeployDacpac.ps1" -projectPath "C:\Program Files (x86)\Jenkins\workspace\Test12_master" -dacpac "C:\Program Files (x86)\Jenkins\workspace\Test12_master/bin/Debug/DatabaseUT.dacpac" -publishProfile "C:\Program Files (x86)\Jenkins\workspace\Test12_master/DatabaseUT.publishprofile.xml"
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Data.Tools.Utilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Microsoft.Data.Tools.Schema.CommandLineTool.Program.Main(String[] args)
Update: Now after changing path of sqlpackage.exe from my local folder to visual studio...\SQLDB\DAC\140\sqlpackage.exe" deployment works fine. But it shows that tSQLt unit tests step run successfully. Its not showing proper message any test case failed or passed.
Here is some ending result lines from unit test run step:
"...
Installing package 'AgileSQLClub.tSQLtTestAdapter' to 'C:\Program Files (x86)\Jenkins\workspace\Test17_master\Lib'.
CACHE https://api.nuget.org/v3/registration5-gz-semver2/agilesqlclub.tsqlttestadapter/index.json
Package "AgileSQLClub.tSQLtTestAdapter.0.59.0" is already installed.
Microsoft (R) Test Execution Command Line Tool Version 16.6.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 158 test files matched the specified pattern."
It consideres all sps including tSQLt sps above in 158. But no result mentions if any unit test passed or failed.
Please guide.
Instead of SSDT project, I am using batch command to run tsqlt test cases through jenkins. i.e. sqlcmd.
So no need to dig more

TFS build does not apply the value of $(VSInstallDir) macros

I have a build-machine and I have made simple changes recently to run editbin.exe tool with LARGEADDRESSAWARE parameter right after each building. The tool is located in C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin (of course, the path can be another). And I have added new target to the build.proj file:
<Exec command=""$(VSInstallDir)\VC\bin\editbin.exe" /LARGEADDRESSAWARE "Manager.exe""/>
If I run MS Build locally on the build machine it works properly. Good! But after any checkin build is not able to be completed with the following error:
The command ""\VC\bin\editbin.exe"" exited with code 3. As I understand TFS build does not apply the value of $(VSInstallDir) macros (C:\Program Files (x86)\Microsoft Visual Studio 12.0\ in my case). Any suggesting?
To resolve the problem I did the next: In VS build config: Process->Build process parameters->5. Advances->MSBuild arguments added /p:VSInstallDir = Value

TFS 2013 does not publish .coverage file on server

I'm developing a quality workflow with TFS 2013 and SonarQube 4.5.1. Everything works fine except one thing: I can't integrate code coverage data from TFS to SonarQube. The problem is that SonarQube needs .trx or .cover files to work.
However, my TFS Build doesn't publish those files. What I've done: I created a CodeCoverage.runsettings file that I mapped on my build with "User defined" type. (With CodeCoverageEnabled it doesn't work either.) In the file CodeCoverage.runsettings, I wrote the following XML tag:
<RunConfiguration>
<ResultsDirectory>.\TestResults</ResultsDirectory>
</RunConfiguration>
in the hope that it would write all the results files in the same directory. The build does indeed create the results directories, but none of them contain .coverage files. However, at the end of the build, in the results page, I can download a .coverage file. Do you know how I can force the writing of this .coverage file on the server? When I run analysis on my local config, the file is created in the test results directory.

TFS Build Server "Can't find the valid AspnetCompilerPath" for TeamBuild publishing a Website

I am having a problem with TFS2013 using a Team Build which does a build then a publish of a website.
Everything works fine when I do a Publish Web site from my dev machine using VS2013 and the (right-click) Publish Web site
option for the Web site project. I get the following error on the TFS2013 Build server:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets(421,5): error :
**Can't find the valid AspnetCompilerPath** [C:\Builds\3\Web\Development to WebDev\Sources\Web\Website\Development\ASP.NET\App\website.publishproj]
Done Building Project "C:\Builds\3\Web\Development to WebDev\Sources\Web\Website\Development\ASP.NET\App\website.publishproj" (default targets) -- FAILED.
**
I am using the follow MSBuild arguments in the Team Build setup.
/p:DeployOnBuild=true;VisualStudioVersion=12.0;DeployTarget=WebFileSystemPublish;PublishProfile=Development
The Development Web Transform works fine on the Build Server in response to the 'PublishProfile=Development' argument. The
Web.Config file is properly transformed for our Development environment.
As noted in the MSBuild Argument, I use the FileSystem publish option and want to keep it that way.
I have modified the Build Server 'C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets'
to log some properties as follows in Target 'ConfigureForAspNetPreCompileMerge':
<Message Text="[TargetFrameworkVersion]: $(TargetFrameworkVersion)" />
<Message Text="[AspnetCompilerPath]: $(AspnetCompilerPath)" />
<Message Text="[Framework40Dir]: $(Framework40Dir)" />
<Message Text="[MSBuildToolsRoot]: $(MSBuildToolsRoot)" />
<Message Text="[MSBuildRuntimeVersion]: $(MSBuildRuntimeVersion)" />
Which logs the following information to the website.log file for the Team Build:
ConfigureForAspNetPreCompileMerge:
[TargetFrameworkVersion]: v4.0
[AspnetCompilerPath]:
[Framework40Dir]: C:\Program Files (x86)\MSBuild\v4.0.30319
[MSBuildToolsRoot]: C:\Program Files (x86)\MSBuild\
[MSBuildRuntimeVersion]: 4.0.30319
The [Framework40Dir] is different than my local machine logging the same data at the same MSBuild target:
12> Task Parameter:Text=[TargetFrameworkVersion]: v4.0 12>
[TargetFrameworkVersion]: v4.0 12> Task
Parameter:Text=[AspnetCompilerPath]: 12> [AspnetCompilerPath]:
12> Task Parameter:Text=[Framework40Dir]:
C:\Windows\Microsoft.NET\Framework\v4.0.30319 12> [Framework40Dir]:
C:\Windows\Microsoft.NET\Framework\v4.0.30319 12> Task
Parameter:Text=[MSBuildToolsRoot]: C:\Program Files (x86)\MSBuild\ 12>
[MSBuildToolsRoot]: C:\Program Files (x86)\MSBuild\ 12> Task
Parameter:Text=[MSBuildFrameworkToolsRoot]:
C:\Windows\Microsoft.NET\Framework\ 12>
[MSBuildFrameworkToolsRoot]: C:\Windows\Microsoft.NET\Framework\ 12>
Task Parameter:Text=[MSBuildRuntimeVersion]: 4.0.30319 12>
[MSBuildRuntimeVersion]: 4.0.30319
The TeamBuild value for [Framework40Dir] is: 'C:\Program Files (x86)\MSBuild\v4.0.30319' vs
my local DEV machine of: C:\Windows\Microsoft.NET\Framework\v4.0.30319
This seems very unusual.
I have also changed the TeamBuild file: 'C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets'
to manually set the property of Framework40Dir as 'C:\Windows\Microsoft.NET\Framework\v4.0.30319'
but that seems to hang the whole TeamBuild process when it gets to that point and runs the Team Build forever until I manually stop it.
This is the same solution that worked here: TFS Build Server cannot get publish profile to work: "Can't find the valid AspnetCompilerPath"
but it doesn't work for me. That issue is identical to my problem.
The Build server is up to date with TFS2013.3. I do not have Visual Studio 2013 installed on that machine and would very much like
not to do that. I have read that VS is not needed for TFS Team Builds.
Help with this issue is very much appreciated.....Thanks.
I would install vs2013 onto the build server it removes the majority of these issues, allows you to run code coverage against your unit tests and doesn't require a licence as long as you have a valid licence on your development machine. I know this isn't the answer you wanted.
I have found the secret sauce. I needed to set the ToolsVersion in my website.publishproj file Project section to "12.0".
I also needed to set the ToolsVersion to "12.0" in the DefaultTemplate.xaml 'Run MSBuild for Project' workflow activities as detailed in this article.
Building Visual Studio 2013 solutions with your TFS 2010 / 2012 Build Templates
The TeamBuild now works like the VS2013 Publish Web site....but this whole process takes almost twice as long as the former Web Deployment Projects we used before. I will have to investigate if there is some way to speed up the Publish process.
Hope this helps someone else with this issue.
please change the $(Framework40Dir) with this path C:\Windows\Microsoft.NET\Framework\v4.0.30319.

MSBuild not copying files with PublishProfile

I have a Visual Studio 2013 solution with the full Orchard source code. When I use "Publish..." on the "Orchard.Web" project in Visual Studio, it correctly publishes the site to the File System destination I've configured into the .PubXml file that I used.
However, if I build this site using Jenkins, the files do not get copied to the destination. I've created a separate PubXml file that is used by Jenkins.
In my Jenkins job, I have two Build steps of interest. The first uses the src\Orchard.sln file with a command line argument of /p:Configuration=Release. This runs correctly, and builds the entire solution.
The second Build step, immediately after, uses the Build File of src\Orchard.Web\Orchard.Web.csproj and these command line arguments:
/p:DeployOnBuild=true
/p:PublishProfile="D:\workspace\Site\trunk\src\Orchard.Web\Properties\PublishProfiles\Jenkins.pubxml"
/p:VisualStudioVersion=12.0
/p:Configuration=Release
/p:Platform=AnyCPU
/v:minimal
/nologo
/p:WarningLevel=1
With this, the build and deploy seems to work - but doesn't. Here are some lines from the build output:
Copying all files to temporary location below for package/publish:
obj\Release\Package\PackageTmp.
Auto ConnectionString Transformed obj\Release\Package\PackageTmp\Shapes\Scripts\Web.config into obj\Release\CSAutoParameterize\transformed\Shapes\Scripts\Web.config.
(... about 200 more "Auto ConnectionString..." lines...)
Finished: SUCCESS
No where does it actually copy the files to the destination defined in the PUBXML file.
In contrast, in Visual Studio, the output looks similar, but transforms only 4 config files and includes lots of "Publishing folder x" lines:
(...)
Transformed Modules\SH.GoogleAnalytics\web.config using ....
Copying all files to temporary location below for package/publish:
obj\Release\Package\PackageTmp.
Publishing folder /...
Publishing folder bin...
(etc.)
(I have installed the latest Windows Azure SDK for .NET on the Jenkins server.)
I have the same trouble,that work for me:
/t:Rebuild
/p:DeployOnBuild=true
/p:PublishProfile=Jenkins_Publish
/p:Configuration=Release
do not use /p:VisualStudioVersion=xxx
This is kind of old, but I actually just set up Orchard to be able to get built via command line and MSBuild. Here is what I did:
/p:VisualStudioVersion=12.0;PublishProfile="example-profile";DeployProjA=true;FrameworkPathOverride="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v4.5";Configuration=Release;PublishProfileRootFolder=c:\Workspace\src\Orchard.Web\Properties\PublishProfiles;Password=ExamplePass
Since you are using Orchard you want to make sure that only the Orchard.Web project gets published so do not use DeployOnBuild=true. This will attempt to deploy every web project in the solution, which is a lot for Orchard. Instead follow the guidelines here to see how to deploy only the web project: http://sedodream.com/2013/03/06/HowToPublishOneWebProjectFromASolution.aspx

Resources