TeamCity Setting up MSTest 2012 - teamcity

On the TeamCity server we have installed VS 2012.
I have created a build configuration in TeamCity that builds and deploys the solution.
I have added a MSTest 2012 Configuration as well, but don't know how to tell it what project is the VS 2012 test project so that it can run those tests.
Thanks

You need to specify assembly file (dll) of your tests, not the project file (csproj).
Here's an example: http://shrani.si/f/p/PH/2tO4Zo5s/tmpa4cc.jpg
So let's say your Testing assembly is called Company.Tests.dll and it is located in Company.Tests/bin/Debug/Company.Tests.dll
Basically, in "List assembly files:" you must put the path (You can use wildcards)
For example:
**\bin\**\*.Tests.dll
This will locate all assemblies with .Tests.dll suffix.
Regards

Related

NUnit3 multiple App.config files in Teamcity

I'm having a strange problem. I have a bunch of integration tests projects. Each test project has a configuration file (app.config).
Currently, in my "Run Integration Tests" build step, the NUnit3 console runner allows me to specify only one config file (where it says "Path to application configuration file"). I have specified the path to one of my integration test app.configs. The problem is, the tests in other test projects fail because the Nunit3 console doesn't recognize their app.config files.
How can I have TeamCity run each test project with its own app.config file in its bin/release folder?
FYI: This is what I have specified in the NUnit assembly lookup: **\bin\Release\*.Integration.Tests.dll
Turns out, this was my problem. After removing all references between my test projects, I noticed that the build time was reduced by 50%.

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. ;)

TeamCity publish using Visual Studio 2015

I've read many articles on publishing from TeamCity using various versions of Visual Studio. I'm currently using v.9.1.7 of TeamCity and Visual Studio 2015.
I have my 3 build steps on check-in:
Clean & Rebuild
Unit Test
Publish
When I check in my files I get a Tests Passed success message:
I can tell from here something isn't right as I'm expecting it to say something about publishing. When I look at the Build Log I see the following:
[12:48:22][API\API.sln] Publish [12:48:22][Publish] MSBuild [12:48:22][MSBuild] API\API\API.csproj: Build target: Publish
[12:48:22][API\API\API.csproj] _DeploymentUnpublishable
My Publish Build Step is setup this way:
In my API project in Visual Studio I can publish to the correct location on the network. Here is my publish profile:
I'm not sure what I'm missing. I'm expecting the Publishing build step to work like when I click the Build->Publish menu item in Visual Studio.
I'm guessing that I'm missing something or misunderstanding what the publishing build step is supposed to do.
Any help is appreciated.
I was able to get it to work after days and days of searching. I found part of the answer here on Stack Overflow. The trick was to get it to work from the MSBuild Command Line:
C:\TFS\project\myProject\APIproject>msbuild apiproject.csproj
/p:DeployOnBuild=true
/p:PublishProfile="Properties\PublishProfiles\DEV.pubxml"
/p:VisualStudioVersion=14.0
Once I got this running several times I was able to create a Build Step in Team City (see this question/answer) and I set the following:
Build file path: <location of the apiproject.csproj>
MSBuild version: Microsoft Build Tools 2015
MSBuild ToolsVersion: 14.0
Run platform: x86
Command Line Parameters: /p:DeployOnBuild=true /p:PublishProfile= "C:\TFS\API\API\Properties\PublishProfiles\DEV.pubxml" /p:VisualStudioVersion=14.0
IIRC, publishing from TeamCity requires certain files or alternatively VS installed on the build agent (which really isn't recommendable). Have you copied the necessary files to the build agent?
Where are artifacts location defined.
And you can use Tentacles for publishing build into various environments.
I guess, you need to look towards artifacts configurations.
You can use MSBuild runner to Deploy your Application/API
Add Command line parameter :
/t:Clean /p:DeployOnBuild=true /t:build /t:publish /p:PublishProfile=C:\_works\teamcity\publishprofiles\Publiush_Profile.pubxml /p:VisualStudioVersion=12.0
PublishPrfile URL should be your publish profile path.
This will work for you.
VS will probably find your publish profile with just the name, like:
/p:DeployOnBuild=true;/p:PublishProfile=DEV; very useful if you run more than one build agent.
And if you're deploying to an IIS you might need to add AllowUntrustedCertificate=true;

Deploying .NET with Jenkins/Hudson

I've been using Jenkins/Hudson CI for deploying my .NET web site project. I've been using the MSbuild plugin to build my project, and then xcopy to copy it out to the server.
I've noticed if I use the publish feature in Visual Studio I get a different set of files. I've got the config transforms working, but I end up with all the .cs files and a winmerge compare shows the binaries being different.
So, I'd like to either get Jenkins working just like the publish feature, or confirm that an xcopy deploy is functionally the same thing.
I've had good experiences with using Web Deploy and as a final build step with Jenkins running a bat file containing:
msdeploy.exe -verb:sync -source:package=%PACKAGE% -dest:auto,ComputerName=%TARGETHOST%
You'll have to install the web deploy package on your build server and the extention on IIS.
I'm using the MSBuild Jenkins plugin to build and then deploy the project. As mentioned in other answers, you need to have Web Deploy installed.
In the project configuration page in Jenkins, you need to add the following to the Command Line Arguments field:
/p:Configuration=Debug /p:DeployOnBuild=true /p:PublishProfile=publishProfileName
Of course, you need to first create the publish profile, either in VS or by exporting it from IIS and you also need to specify the solution file path in the MSBuild Build File field.

TeamCity - Configure MSTest Settings to execute a command before the tests

I try to configure the MSTest Settings ssection [Step 3 Runner: Visual Studio (sln)]. My particular configuration require to call a set of scripts (TestSetup.cmd) before the tests. Everything works fine in Visual Studio, but I don't know how to call the scripts from TeamCity.
I tried to add in the MSTest metadata the .vsmdi file but without success. The script are not executed.
My question is how to call the command from TeamCity in the MSTest Settings section?
Thank you and best regards!
testrunconfig file:
This is a default test run configuration for a local test run.
MSTest Settings screen shot TestSetup.cmd
Versions :
TeamCity Enterprise 5.1.3
Microsoft Visual Studio Team System 2008 Development Edition
I
Add a build step before the MSTest runner which runs your testsetup.cmd.

Resources