I have a trouble with understanding how to use devenv.exe from TFS Build Server.
There is no default step to use devenv, so I tried to use PowerShell sсript to execute devenv.exe with parameters. There are no errors in build process but I see that build result files are not updated.
If I execute the script manually on a agent-machine, the build passes successfully. That is my script:
$process = [System.Diagnostics.Process]::Start( "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe", "/Rebuild ""MyConfig"" ""C:\agent\agent\_work\1\s\MyProject.sln"" /Project ""C:\agent\agent\_work\1\s\MyProject\MyProject.dwproj""")
$process.WaitForExit()
As you see now I do not use variables for source paths, but I will use it if script will work.
I also have to say that I could not find any logs with errors. Maybe I do not know where to find them?
So,
What am I doing wrong in powershell script?
What is the best practice to build project using devenv.exe in TFS Build Server?
PS We are using TFS 15 RC1 (Version 15.103.25603.0).
For now, there is no this build-in feature to support directly using devenv.exe in vNext build task. But seems will coming in the near future:
That is not something we are working on right now, but it is something
that we would take a pull request for.
chrisrpatterson commented on Jan 8
We want an input on the existing Visual Studio Build task that says
use devenv (defaults to false). If true, it takes the variant path
running code similar to above.
bryanmacfarlane commented on Jan 22
Source from GitHUB:
"Visual Studio Build" build step that actually invokes devenv.com instead of msbuild?
visual studio command-line build vnext step (devenv.com)
You can try to use a pull request provide by jmacnett which creating a customize build task.
I found that it doesn't work only when the agent is running as a service. When I started the agent in the interactive mode, my tasks started to work correctly. Why? - I don't know.
$argumentList = ("`"$solnPath`" /$solnCmdSwitch $solnConfigName")
if project then add folowing
$argumentList += (" /project `"$projPath`" /projectconfig $projConfigName")
See the extra back-quotes
Related
I set up a new TFS Build Server recently and I'm investigating some extended time periods during the build process. One of those periods is the recompiling of our Selenium test .dll. First, the packages are restored via MSBuild, which is fine. Then, the script hangs for about 10 minutes, while the .dll is actually compiled.
This worked fine on our Visual Studio 2017 Build Server, (took a few seconds to compile I believe) but seems problematic with 2019.
Here's the code. Am I missing an MSBuild parameter or two?
$msbuild = """C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe"""
# Rebuild the Test source .dll...
Write-Host "********** Running UI Tests **********"
# Restore Selenium packages...
Write-Host "********** Restoring Selenium Packages **********"
&"C:\Nuget.exe\Nuget.exe" restore $source\Development\12.0\Web\MyAppWeb\MyCo.SeleniumUITest\MyCo.SeleniumUITest.sln -DisableParallelProcessing
Write-Host "********** Selenium Packages Restored **********"
# Changes for new MSBuild....
$projfile = "$source\Development\12.0\Web\MyAppWeb\MyCo.SeleniumUITest\MyCo.SeleniumUITest.sln"
try
{
start-process $msbuild -ArgumentList #($projfile,'/t:Rebuild','/p:configuration=Release') -Wait
Write-Host "********** Selenium .dll compiled successfully! **********"
}
catch
{
Write-Host $_.Exception.Message
exit 1
}
Any Help Appreciated! If this should go in the PowerShell forum, let me know. I thought TFS/MSBuild would be the correct place as I'm hoping its just a parameter or call tweak.
MSBuild Running Slow Called from PowerShell Script (Visual Studio 2019)
State:
(It is difficult to give an accurate answer to this question of operating efficiency. There are many reasons for the problem, most of which are related to the environment, making it difficult for us to reproduce it. So we could not give the direct correct answer for this issue, we can only give you some troubleshootings. In order to avoid losing contact in the round-trip comments, I post those troubleshootings as answer instead of comments.)
First, use the script with Azure devops service instead of the TFS Build Server 2019, to check if this issue still occurred on the Azure devops service, if this issue also occurred on the Azure devops service, that mean this issue should not related to the TFS, more related to the MSBuild/environment/powershell scripts.
Second, use the build in task nuget restore and msbuild task instead of the powershell scripts, to check if you have this issue, if also have this issue, this issue should not related to the scripts. If not, this issue should related to the scripts. We need to check if this scripts need to update since we use the different TFS server.
Third, Check the powershell version in the Visual Studio 2017 Build Server and Visual Studio 2019 Build Server, make sure they use the same version.
If you still could not find the reason, you could enable the debug log and share the log about the hangs to us, so that we could get some more info.
Hope this helps.
I moved the MSBuild scripted tasks out to Build Definition tasks to remove the slowness. I did not determine the cause of the hang when MSBuild was called via the PowerShell script.
The later issue of trying to publish via a .proj file was solved when I noticed I was using a Visual Build task instead of the more appropriate MSBuild task.
One thing to note when using the MSBuild step. If pointing to a .proj file and compiling for Any CPU, set it in the Task as AnyCPU with no space in between.
I want to use a powershell script to queue a TFS build( prompting the user to enter the custom build defination) and wait until the build completes and check the status of that build and do a copy if it succeeds or exit if it fails. I would like to thank you in advance for taking time to answer my question
The simplest way is to use tfsbuild.exe command. This tool is located in Drive:\Program Files\Microsoft Visual Studio xx\Common7\IDE. More detail info to use start command: https://msdn.microsoft.com/en-us/library/ms181742(v=vs.100).aspx
You can also use a script using the APIs, How to queue another TFS (2012) Build from a TFS Build AND pass process parameters?
Which things your want to copy? In the build definition, you can specify a drop folder to copy your build outputs in it.
I am trying to deploy Visual Studio 2012 SSDT project to Sql Server using TeamCity 8 and MSBuild Publish task but the deployment fails.
When I look at TeamCity logs and use /v:diag switch in my build configuration I see that for unknown reason MSBuild searches for MyProject.sqlproj.publish.sql and for MyProject.sqlproj.dacpac files.
The exact error:
[SqlPublishTask] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets(1233, 5): File "C:\Program Files\TeamCity\buildAgent\work\abf8bc05a2cfe7f\*MyProject*\bin\Debug\*MyProject*.sqlproj.dacpac" does not exist.
The correct .sql and .dacpac files get generated (without the .sqlproj in the middel) in buildAgent/work/identificator/*MySolution*/MyProject/bin/Debug folder.
My TeamCity build step is configured as follows:
Runner type: MSbuild
Build file path: MyProject/*MyProject*.sqlproj
MSBuild version: 4.5
MsBuild ToolsVersion: 4.0
Run platform: 4.0
Targets: Publish
Command line parameters: /p:SqlPublishProfilePath="Debug.publish.xml" /p:Configuration=Debug
If I execute this from commandline I get no errors.
Any ideas on how can I configure TeamCity to search for correct files or configure my project to generate the files that TeamCity is searching for.
Or is my plan to use MSBuild's Publish task futile and I should utilise sqlpackage.exe instead?
UPDATE
After spending almost three days trying to figure this out I gave up and used sqlpackage.exe which works like a charm.
But I would still be interested in an answer though, passing paths to executables in build servers seems a bit crude way to accomplish things.
I had a similar issue and came to the conclusion that the way TeamCity produces "pseudo-project" files with *.teamcity suffixes is confusing something in the MSBuild/SSDT target chain.
I simply replaced the MSBuild runner build step with a pure Command Line step and the problem went away.
We lose the user friendliness of the TeamCity MSBuild runner configuration, but if it works, it's a compromise I'm willing to make.
Note - we are running TeamCity 7 - I am not sure if this has been addressed in later versions.
I found out you can set a System Property named "system.SqlTargetName" on the build configuration to override the default value.
Setting this to your project name without the ".sqlproj" makes the error go away.
I use VS 2008, Team Explorer and TFS. I'm looking to automate your builds by executing TFSBuild.exe command.
I follow those steps:
Open TeamExplorer, in VS2008, connected to TFS;
My Team Project has a Build (named MainBuild) in Builds. Then, I do Query New build option.
I fill the properties in window dialog opened:
build Definition: Mainbuild
Build Agent: Machine1BuildAgent
drop folder for this build: \Machine1\Build_drop
priority in queue: Normal
MsBuild command-line arguments:
/p:BuildAll=false /p:RunTest=false /p:SkipClean=true /p:SkipGet=true /p:SkipLabel=true /p:SkipGetChangesetsAndUpdateWorkItems=true
In MDSN I have seen TFSBuild command and this sample:
The following example builds the Nightlies build type which is in the AdventureWorks team project on server01. The resulting build is located on Machine1 in the BuildDrop directory.
TFSBuild start http://server01:8080 AdventureWorks Nightlies /m:Machine1 /d:"C:\BuildDrop"
edit: Now, for my issue, how can I do automation for build MainBuild for set the values for "MsBuild command-line arguments" using TFSBuild.exe command ? I'm looking for a way to automatically have the TFS Build Agent job run nightly with command-line arguments..
I need similar command line like this:
TFSBuild start http://machine01:8080 MyteamProject MainBuild /m:Machine1 /d:"\Machine1\Build_drop" /p:BuildAll=false /p:RunTest=false /p:SkipClean=true /p:SkipGet=true /p:SkipLabel=true /p:SkipGetChangesetsAndUpdateWorkItems=true
I need pass the arguments (MsBuild command-line arguments) to TFSBuild.exe command and automatize the TFS build.
any sample scripting code ?
You can pass MSBuild properties to TFSBuild using the /msBuildArguments switch
TFSBuild start http://machine01:8080 MyteamProject MainBuild /m:Machine1 /d:"\Machine\Build_drop"
/msBuildArguments:"/p:BuildAll=false;/p:RunTest=false;/p:SkipClean=true;
/p:SkipGet=true;/p:SkipLabel=true;/p:SkipGetChangesetsAndUpdateWorkItems=true"
Alternatively, you could also specify these properties in the response file TFSBuild.rsp.
I'm not sure I understand your question clearly, but if you're looking to automate your builds by executing MSBuild from the command-line, you can create a batch file to execute the necessary command using the command-line arguments you want. Then add a scheduled task to 'Scheduled Tasks' in Windows so that this batch file is executed on a regular (e.g. nightly) basis.
Following a MSDN web page, I am trying to manually run mstest within my tfsbuild.proj and put the results into the pass/fail logic so the build will fail if this particular test fails. It's kind of like running a FxCop or something else from CMD and capturing a "0" or "1" and force-fail the build.
MSTest /testcontainer:test.dll /publish:http://ourtfsmachine:8080 /teamproject:ProjectName /publishbuild:BuildNumber01 /platform:AnyCpu /flavor:Release
I could understand running this inside an Exec task, butI don't know what the BuildNumber is, for example.
Help?
Instructions for getting the Build Number from http://msdn.microsoft.com/en-us/library/ms243151%28VS.100%29.aspx:
Open Visual Studio and connect to a Team Foundation Server.
Open Team Explorer.
Open your team project and expand the team project node.
Under the build, double-click All Build Types or a specific build type to see its builds. Build names that you can use are in the Name column.