I want to setup the TFS to build both Debug and Release versions of my solutions but only run the unit tests when in Debug mode. I've tried disabling the builds for the test projects in my solutions' Configuration Properties, but to no avail. And what's annoying is that the tests will always fail in Release mode because it can't seem to find the files even though they exist...
So anyone know how to get TFS to run the unit tests only in Debug mode (but still build both Debug and Release modes)?
In VS2010:
Team Explorer → Project → Builds → In your "Build Definition" select Edit Build Definition → Process
Here you should configure:
1.Required → Items to Build: select herer project and configuration to Build, i.e. Release or Debug in your case
3.Advanced → Disable Tests: True/False
I've finally found out how to do it. In the TFS build definition file (.proj), under the section for listing out the test list/DLLs, just add a $(Configuration) condition to each item as follows:-
<ItemGroup>
<MetaDataFile Condition="'$(Configuration)'=='Debug'" Include="$(BuildProjectFolderPath)/SubFolders/MyTestListFile.vsmdi">
<TestList>My Test List Name</TestList>
</MetaDataFile>
<TestContainer Condition="'$(Configuration)'=='Debug'" Include="$(OutDir)\MyTests.dll" />
</ItemGroup>
Related
I m using VSTS build task for building msi files from installer projects.
I get below log message and no msi file is generated(project is being skipped always from build) . I don't see platform option dropdown to select "Any CPU " from build configuration manager.
Please help. Click on the below links to see screen shot of build configuration and build task
build configuration
Build tasks
------ Skipped Build: Project: Setup4, Configuration: Release ------
Project not selected to build for this solution configuration
However msi file is generating fine when I do manual build on setup project. Not sure why platform option is missing for setup project..?????
From the build log, TFS is using Release Configuration. And from the log, it seems that your project doesn't select build configuration for Release configuration.
So, in the configuration manager of Visual Studio, select build for release configuration. Then check in to TFS.
You should pay attention that, both project and solution has configuration settings. If you want to build solution in TFS, change the solution settings. If you want to build project in TFS, change the project configuration settings.
on my CI server running TeamCity 8.0 I have a build configuration whose last steps are the creation and the push of a new version of a NuGet package.
I wonder if there is a way to inhibit these two steps if the current build is a personal one.
Any clue?
There's an environmental variable thats exposed in teamcity that can tell you if this is a personal build BUILD_IS_PERSONAL :
See http://confluence.jetbrains.com/display/TCD7/Predefined+Build+Parameters
E.g. using the msbuild runner (you just need to supply the nuget path)
<Project DefaultTargets="Pack" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Pack" Condition="$(BUILD_IS_PERSONAL)!='True'">
<Message Text="Personal: $(BUILD_IS_PERSONAL)"/>
<Exec Command="$(NUGETPATH)\nuget pack $(NugetProject)"/>
</Target>
</Project>
Alternatively, you could halt the condition of build steps using an extra build step. thereby making them conditional:
Add an extra build step that uses the powershell-
if (([environment]::GetEnvironmentVariable("BUILD_IS_PERSONAL","Process")) -eq "True")
{
throw
}
On each build step there is the option:Execute step
If you choose the option "If all previous build successfully" then the step will be passed
If you choose: "Even if some of the previous build steps failed" it will execute.
TeamCity 2020.1 has added support for conditional build steps, and there is a quick shortcut to skip the build step for personal builds.
You could create a new build configuration - leaving out those 2 steps. Then - install the TeamCity Visual Studio plugin (assuming you are using VS) and then run a personal build, choosing the build configuration you'd like to use.
Similar to Jordan's response I think the best approach is to separate compilation from packaging / deployment build configurations. In fact if you use Octopus to deploy then you have to keep the TeamCity Octopus deployment steps in a separate build configuration from the compilation as the NuGet feed doesn't get populated until after the build configuration has been completed successfully.
If make your packaging / deployment build configuration a dependency of the compilation build configuration and set the build trigger to only trigger after a successful build of the compilation build configuration, then it will not trigger after a personal build even if that is successful : -
This way you are always calling the same build configuration for compilation, whether via Developers on VS using the AddIn or Release Team via the Web UI
Hope this helps
We have a similar issue where we only wanted to build-and-deploy our local Apache Maven repository when it has changed.
One possible solution: If your build step is a Command Line (or can be), create a tiny shell script to decide if these step should be run or not.
We have a large non Visual Studio C++ project which is build via a batch file. I have integrated this up in Visual Studio as a makefile project with customised 'Build Command Line' in the project properties, this works well and has done for over a year.
I am now looking to introduce Team Foundation Server and configure automated builds.
If I build the project in Visual Studio then the project build as normal.
If I use the automated build sever to build the project the build fails every time
The option to view the log file in the build report is greyed out. The report given is
The command "Autobuild.cmd" exited with code 1.
Where autobuild is the cmd file specified in the solution's 'Build Command Line'.
Can anyone think of a reason why this might be the case, I assumed that the build sever would just run the Build command with the project specified in the 'Items to Build' box. If this is the case then I cannot see why it would fail.
There are loads of possible reasons; unfortunately you've not given enough information to answer that questions.
The first thing to try is changing your build definition logging level to Diagnostic. (you can also do this when you queue a new build).
What I also recommend is actually wrapping your makefile in an msbuild.proj file.
Something simple like:
<Project ToolsVersion="4.0" DefaultTargets="build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="build">
<Exec Command="autobuild.cmd" />
</Target>
</Project>
The Exec task has loads of options to customize how the cmd is called and should help you diagnose your error.
In general if you want to take advantaged of TFS builds I'd recommend migrating as much of your autobuild.cmd to msbuild as possible. MSBuild is TFS's "makefile" language, so-to-speak.
In your build definition you have an option of logging, there you can change that to Verbose logging. Maybe you get some information in your log file then.
And for the issue of exited with code 1 I think you will need to add some extra informational lines to be printed in the cmd program and when your logging in TFS Build is active you maybe see more information on it.
I've recently installed VS 2010 Ultimate, and decided to move a project to TeamCity, The project contains a few *.dlls with unit tests inside.
In VS 2008 the setup procedure, at the build runner stage, would consist of :
Setting the path to the *.sln file
Setting the VS version (2008)
Setting the target(s) such as : "Clean Build"
Setting the configuration such as : "Debug"
Setting the platform sucha as : "any cpu"
Checking the "Enable MSTest tests" checkbox
Setting the path to MSTest.exe (pickable from the list of shortcuts)
Listing the assembly files : (1st one beging the dll called : Microsoft.VisualStudio.QualityTools.MSBuildTasks.dll)
Picking the MSTest *.trx test results file
In VS2010 the forementioned dll file is gone, and I'm unable to setup the MSTests, does anyone have a recipe how to do that?
edit : replaced config file with the *.trx file line
I am currently using MSTest with VS2010 on TeamCity and the tests are working perfectly. These are the only steps I had to do for the MSTest part:
Checking the "Enable MSTest tests" checkbox
Setting the path to MSTest.exe (pickable from the list of shortcuts)
Listing the assembly files
I did not have to select the .trx test results file or add Microsoft.VisualStudio.QualityTools.MSBuildTasks.dll to the list of assemblies, and all of the other fields in the 'MSTest Settings' section are empty.
I have a report project that I want to script deploying to a development server. I need to just change the TargetServerUrl in the project properties. Is there a way to do this?
i.e.
&devenv.exe RSReports.sln /project Reports\Reports.rptproj /deploy
maybe => properties:TargetServerUrl=http://myserver/ReportServer
I know nothing about report projects but in almost every VS project you can define multiple "Configuration"s (the defaults are Debug and Release). So you can have one target in debug and another in Release mode, and use the command line
devenv /deploy Release RSReports.sln
Another option is to use the msbuild.exe utility to build your project (instead of devenv), and use it's proprerty replacemnet parameter
"c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" "Full path to soulution" /t:Build /p:Configuration=Release /p:TargetServerUrl=http://myserver/ReportServer