I have a TFS 2015 build in which I want to run command 'dotnet restore'. On my build machine, the path to dotnet.exe is part of my environment variable 'Path'. When running the command from command prompt window, it works fine. When trying to run it via a TFS build step of type 'Command line' dotnet is not recognized. My path variable containing dotnet.exe path is at system level, so every users, including the one on which my build agent is running, should see it.
I have tested with TFS 2015.3, after adding dotnet.exe path in Environment Variables and add Command Line step in build definition, dotnet.exe can be recognized in the following setting. You may compare it with yours:
FYI, this is still an issue with TFS 2017 as well. From my tests, it appears TFS doesn't like when the PATH variable is over 900 characters. After shortening the PATH variable and closing the dialog windows, restart the VSO/VSTS agent services and you should see the Path variable appear as a capability for the agent. Hopefully this helps someone else.
Related
I've recently started to encounter a problem with a new build agent that I have added to my TFS agent pool. The agent runs my build the first time without any problem. However, all subsequent builds fail with this error "##[error]The directory is not empty". This occurs on the initial startup of the build when it is trying to download files from TFS.
Keep in mind that I have set the "clean" option to true for the build and also set the Build.Clean variable to "all"
I've done searches online for this error and most of the info I am finding states that the directory is in-use and that is why it cannot be deleted. The strange thing is that I can manually delete the folder using Windows Explorer and there is no error reported of files in-use. Once I do that, the build will work again, but only on the first run. Why is it that the TFS vNext build cannot delete this folder? Is there a log that I reference that provides more details other than "directory is not empty"?
You could set system.debug=true to enable verbose Debug Mode for TFS vNext Build.
In addition, you could also check the agent log under agent path\_diag path here.
If there are more information for troubleshooting.
Back to your issue, please try to stop you build agent service and restart again. Also update your build agent to latest version.
Besides, you could also choose another driver such as D:\ or E:\ if you are using c:\agent\ which may do the trick.
I currently have an on-premises TFS 2017, a TFS build and a test that fails on the build agent but not when running locally. I heard about historical debugging but I couldn't find instructions on how to enable it on a TFS build, if that's even possible.
Is it possible to configure my build so that it generates an intellitrace file for me to debug the test run afterwards?
For intellitrace which related to the old testsettings file and could add some variables to configure this.
You could also manually enable such option in the VS on your build agent.
Also find a link mentioned it seems also work with Msbuild arguments. Even not documented anywhere in Msbuild command doc. I wonder whether IntelliTrace is still running even though it's not explicitly specified to do so
However, looks like you just want to find the root cause why your tests failed on tfs build even it passed locally.
To narrow down the issue, suggest you directly remote to your build agent. Instead of through TFS build, manually build your project, run the tests in the Visual Studio on build agent.
It will come out whether it's an environment issue. You must make sure it's the same environment for build agent and your local.
TFS is just using build service account to invoke msbuild/vstest command in build agent to run build/test.
Also make sure build service account have appropriately permission if your tests required some permission.
I am grappling to understand how Tfs’s VNext build handles NuGet.exe versions under the hood.
I am running a Tfs 2018 (16.122.27102.1) on-prem server.
My agent is running (as a windows service) on my machine on the location “C:\dev\tfs_bld_agents\scully\”
If I understand it correctly the “Nuget tool installer” (1) will ensure that the NuGet.exe version specified in the build task (in this case 4.3.0), will be installed where this build definition is executed by an agent.
The subsequent build task “NuGet Restore”(2) will then run the NuGet.exe installed by the previous build task(1) and will execute the NuGet restore command.
If, however, I search through the build agent's root folder on disk “C:\dev\tfs_bld_agents\scully\” I find an array of different versions of NuGet.exe
3.3.0
3.5.0
4.0.0
4.3.0
Directories, where a version of NuGet.exe resides, are:
What is the reason for this behaviour i.e. having all these different versions within the build agent folder, seeing that the NuGet.exe version specified by my build definition was only version 4.3.0?
Assuming that we for instance do not (or cannot in older Tfs versions) run the “NuGet Tool Installer” build task, how will the Tfs build agent go about figuring out where to find a NuGet.exe on the machine?
These NuGet.exe versions are included in the NuGet Tool Installer task and NuGet task by default. When you queue a build, build agent downloads the tasks build needs, then you will see these NuGet.exe versions.
So I performed some tests attempting to track what happens when you use different versions of NuGet within the “Nuget tool installer” Tfs build task. For the baseline, a Tfs2018 (16.122.27102.1) build agent (of type service) was used, just extracted and configured.
After configuring the build agent, you will have the following NuGet.exe in your agent directory:
NuGet.exe version: 3.3.0 (3.3.0.0212) - Note: this is just after the agent was configured, no builds have been run here!
I then proceeded to set up a build definition that will be executed by agent mulder. The build definition contained the “NuGet Tool Installer” build task. My first try was to specify NuGet 2.8.6 and then run the “NuGet Tool Installer” build task.
After this task was completed, we find the following NuGet.exe artifacts within our build agent folder:
NuGetInstaller
NuGetToolInstaller
As well as the NuGet version we requested, provided on location ...\_tool\NuGet\2.8.6\x64\nuget.exe
From this point onwards, the content of the ...\_tasks\ folder seems to remain constant in regards to NuGet.exe versions, regardless of which version you specify.
The only obvious change being, the addition of every new version you select within this location ...\_tool\NuGet\{version requested}\x64\nuget.exe.
So if we painstakingly select each possible version in the “NuGet Tool Installer” build task and run it, we will end up with a spread that looks like this:
Regarding the logging produced by the agent running the “NuGet Tool Installer” build task, the thing that stands out is the fact that after each switch in the NuGet version, the following message appears: Prepending PATH environment variable. I assume the purpose being to point to the selected NuGet.exe version on disk. In the case of version 2.8.6 we see the following:
Prepending PATH environment variable with directory: C:\TfsBuild\mulder\_work\_tool\NuGet\2.8.6\x64
So what happens if we revert back to a specific version? Let say from v4.5.1 to v2.8.6 - does it clean up some versions?
No. It leaves everything intact but does modify the PATH variable again to point to the correct version you reverted to.
Prepending PATH environment variable with directory: C:\TfsBuild\mulder\_work\_tool\NuGet\2.8.6\x64
An interesting phenomenon is that you cannot see these "Prepending" changes in your PATH environment variable.
If you, however, run the build in debug (by flipping the system.debug variable to true) you see some interesting details. This time around I can see that the variable(s) are indeed slipped in front of the existing PATH variables (that are visible in the environment variables GUI), as well as 2 more at the end.
Debug logging looks something like this:
Prepending PATH environment variable with directory: C:\TfsBuild\mulder\_work\_tool\NuGet\2.8.6\x64
new Path:
C:\TfsBuild\mulder\_work\_tool\NuGet\2.8.6\x64;
C:\TfsBuild\mulder\externals\git\cmd;
.
..
<The existing paths variables>
..
.
C:\TfsBuild\mulder\bin;
C:\TfsBuild\mulder\bin
It thus seems to retrieve the existing PATH environment variable, and then slot in the “new” required variables in front of them while running the build.
Clearly Tfs build is very good at ensuring that there is always a correct version of NuGet.exe at hand, but cleaning up old versions is not its strong suit :-)
I have a java project and I'm gonna build it using a build agent running TFS 2015. I've installed JDK as well as ANT and also set the JAVA_HOME and ANT_HOME system variables. However the build process fails because of the following error message.
Unable to find Ant. Verify ANT_HOME is set and pointing to a valid Ant installation on the build agent: http://ant.apache.org/manual/install.html.
According to the instruction here, I should also install TFS build extensions, but I assume TFS 2015 does not require that and it comes with it by default.
I can figure out what the problem is.
Ensure the user running the tfs build process has %ANT_HOME%\bin on it's %PATH% Setting ANT_HOME is necessary, but not sufficient.
On my local dev machine this works perfectly:
msbuild project.name.csproj /p:DeployOnBuild=true /p:DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="c:\proyectos\folder1\deploy" /p:AutoParameterizationWebConfigConnectionStrings=false
I'm trying to configure a Build step in TeamCity with MSBuild, in the "Command line parameters" I'm putting this:
/p:DeployOnBuild=true /p:DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="c:\proyectos\folder1\deploy" /p:AutoParameterizationWebConfigConnectionStrings=false
It runs, no errors are displayed, but files are not copied to "c:\proyectos\folder1\deploy"
Edit: I'm having the same issues with MSBuild on the command prompt, so it's not teamcity. My local dev machine is on windows 7 and the server is windows 2003
Run with /v:d or v:diag to get logging.
(Get it working local first but... In TeamCity, view the agent in the console and look at the agent detail logs for similar such logs (or just pass the same /v: flag to MSBuild via TeamCity))
You'll want to ensure that the user running the "TeamCity Build Agent Service" has write access to the relevant directories.
(FWIW, I believe the LocalSystem account has different group memberships in Server 2003 and Windows 7. We run all of our TeamCity build agents under their own "teamcity" accounts to more explicitly control permissions and allow access to network shares.)
Installing Visual Studio 2010 DOES fix this problem. But, you can also fix it by copying the appropriate build targets to your machine. Typically, on your dev machine they'll be at (Or take away the (x86) for 32 bit machines):
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web
In there you'll find a bunch of Microsoft.Web.Publishing.* targets.
Just copy those over to the equivalent location on your build machine and all will be well.
Installing Web deploy tool through web platform in the server works for me. Actually visual studio installation installs web deploy, It might be the reason why it works for #himinaya.