Failed to find Visual Studio .sln file - Dynamic parameter for build step template - teamcity

I am fairly new to using TeamCity. We are currently using 9.16.
I am trying to setup a build template to associate across our many projects and I keep getting the error "Failed to find Visual Studio .sln file" for both the NuGet Installer step and Visual Studio (.sln).
Currently it is set to %system.teamcity.build.checkoutDir% and it says there is no *.sln file there, but there is when I look at the build server directly.
Failed to find Visual Studio .sln file at C:\TeamCity\buildAgent\work\58ef95107452dcbc\*.sln
I found the post regarding attaching the VCS root, but I do have that attached and it mirrors the projects that currently do not use a template.
Any help as to what I am missing would be greatly appreciated.

You must put the filename of your visual studio solution file in the "Solution file path" field of the "Visual Studio (.sln)" build runner step.
If your .sln file is at the root of your checkout directory you would specify the filename. Example: YourSolution.sln
For the "Nuget Installer" build runner step you must put the same solution filename in the "Path to Solution File" field.
Note that if your solution file is not in the root folder of your checkout folder you must specify the relative path. Example: path/to/my/SolutionFile.sln

What I was attempting to do is not possible.
Instead I created a parameter at the root level for SolutionFile in the templates. Then I simply change the value of that parameter in each project that uses the template.

In my case I was moving from SVN to GIT with TeamCity, and so had to change the VCS root from:
http://build.server.url:81/svn/MyApp/
To,
http://Build-Server-User#git.build.server.url:7990/MyApp/MyApp.git
Also, I had to change "checkout rules" from:
+:trunk => .
To,
+: => .
Because the default branch in TeamCity for GIT is refs/heads/master
For details, please see https://confluence.jetbrains.com/display/TCD10/Git

Related

TFS 2015 Visual Studio Build - Package .zip not being created

I'm trying to build my solution and package up the web app into a web deploy (.zip) package to be deployed.
I've added the Visual Studio Build step with the following MSBuild Arguments:
/p:DeployOnBuild=True /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:PackageLocation="$(build.artifactstagingdirectory)\"
And I've set up the Copy and Publish Build Artifacts step to copy all .zip files to the drop folder.
The build completes successfully but nothing is copied to the drop folder because there are no .zip packages that get created.
So when I look on the TFS server, the only thing in the 'a' folder is an empty 'drop' folder. And in the 's' folder is the solution directory with a PrecompiledWeb folder in it. Not sure what that is but it doesn't look like the deployment package (and it's not a .zip).
Any ideas?
I have tried the same on VS2015 MVC web application using VSTS and TFS 2015.2.1 both. I had to do a slight change to the Build arguments in Visual Studio build. That is removing the trailing "\" in /p:PackageLocation="$(build.artifactstagingdirectory)\".
Here is the argument I passed to Visual studio build step
/p:DeployOnBuild=True /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:PackageLocation="$(build.artifactstagingdirectory)"
Then I used Copy and Published Build Artifacts (Deprecated in VSTS you should use Copy task and Publish task instead of this task) as shown below
This gives me output as below.
First suggest you manually remote in the build agent and build the project through MSBuild command line with arguments to see if the project builds properly.
This will narrow down the issue is related to the environment on your build agent or your build definition.
You should directly use /p:PackageLocation=$(build.stagingDirectory
Besides since you have multiple assemblies that are referenced in the web app. Please also double check dependencies that are building in the correct order or referenced correctly.
Make sure the ASP.NET development workload of Visual Studio is installed.
If DeployOnBuild is having no effect, you may need to install the ASP.NET Development "workload" with the VS setup tool.
There are specific .targets files that, if they don't exist, cause these parameters to be silently ignored. Installing this adds those .targets and the parameters become active, allowing the .zip to be created.
For me (VS 2017) the relevant target file (or one of them, anyway) that was missing but is needed is:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.targets
If it is missing, you'll need to install as above, and if it is there, then you have a different problem. ;)

Build Wix installer Project in Teamcity 9.1, but how to set the `WixToolPath` in build machine?

I'm using Win10 64bit OS, with Wix3.11RC Toolset installed. My VS2017 have created a Wix v3 installer Project. Our team is using TeamCity9.1 as the CI tool.
Now I want to make the Build Agent in TeamCity to support wixproj build without touch CI server settings(I don't have privilege ). I basically follow some tutorials to checked in all necessary Wix build files(the wix Bin folder, and the wix.targets ) which is put in a relative path to the source code, now I'm blocked with the path issue in editing .wixproj file, the official doc said:
http://wixtoolset.org/documentation/manual/v3/msbuild/daily_builds.html
<PropertyGroup>
<WixToolPath>$(SourceCodeControlRoot)\wix\[[Version]]\</WixToolPath>
<WixTargetsPath>$(WixToolPath)Wix.targets</WixTargetsPath>
<WixTasksPath>$(WixToolPath)wixtasks.dll</WixTasksPath>
</PropertyGroup>
And this is mine:
<PropertyGroup>
<WixToolPath>..\..\wix\3.11\</WixToolPath>
<WixTargetsPath>$(WixToolPath)targetsFile\v3.x\wix.targets</WixTargetsPath>
<WixTasksPath>$(WixToolPath)wixtasks.dll</WixTasksPath>
</PropertyGroup>
The reason I'm using the relative path for WixToolPath is the $(SourceCodeControlRoot) was resolved as D:\ here, but actually the source code will be checked out by CI server and put under a random folder like D:\ABC\f14c7929aa63f1fc. By my configuration, the local build even can't go through, the build error indicates the WixTasksPath had been resolved to a non-existed path: C:\Program Files (x86)\MSBuild\Microsoft\WiX\v3.x\..\..\wix\3.11\wixtasks.dll
So how can I achieve? thanks!
One of the approaches you can try is to change the path in the file to the absolute path using TeamCity-provided references before invoking the tool. In TeamCity settings you can reference the checkout directory path as %system.teamcity.build.checkoutDir% or use ${teamcity.build.checkoutDir} within MSBuild step if run as MSBuild build step.
You can do the replacement in the first build step or just use TeamCity file content replacer to change the old value to new one.
just use
<WixTasksPath>wixtasks.dll</WixTasksPath>
this worked for me.

Build Fails Missing File Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props

I have a brand new Visual Studio 2015 project stored in a TFS Git repo. I've configured a build using the standard Default Git build template. The new project builds locally just fine, but fails during the TFS Build with the following error:
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props.
When TFS first creates your Git repository, it includes a default .gitIgnore file which "hides" certain files from your your (Pending) Changes window. One of the wildcard based exclusions in the default .gitIgnore file specifically excludes any files from being checked in under any folder that includes "build/" which includes this specific file. For now, I've commented out that exclusion in the file, and now it shows up in my (pending) Changes window.

Visual Studio Custom Build Default Directory Incorrect

My Visual Studio 2013 Custom Build Tool step is failing because the directory in which the step is being executed is not the directory where the project file is (which was by default the case up until recently). I can patch it by adding a cd command to the start of the step to change to the project directory but I was wondering if anyone could tell me
how this directory path is set
how to change it.
The build always assumes the project directory as 'base' directory.
This gives msbuild a set location (Builds to bin\debug is a subfolder off 'Base', reference hint paths and a lot more besides).
I would just change the execute of your tool to be reference based (i.e ....\tool.exe or similar) or make use of the path environment variables ($(OutDir),$(TargetPath),$(ProjectPath),$(TargetDir) etc).
Another option that I make use of is to have a batch file called 'post.bat' that has the necessary steps to execute a custom tool. This is then placed in the project folder and added to the project as an artefact.
Without knowing exactly where your custom tool resides relative to the project (or solution) or what the 'working directory' requirements of the custom tool are I cannot suggest more.

Delete additional files when cleaning project

When executing build->clean solution in Visual Studio 2005 I want to also remove some debug text files that may exist in my build directory. The file name will always be the same, i.e. debug.txt. Is there a way to get Visual Studio to do this?
Go to Project->Properties and choose configuration properties.
THere's an entry "Extensions to delete on clean". Add *.txt to it and that just should do the trick. Or you can explicitly specify debug.txt

Resources