please tell me how to run nunit with msbuild. I am using TFS for code integration and VS2010 .
You probably want to integrate NUnit with TFSBuild and not MSBuild since you are using Team Foundation Server.
You will need MSBuild tasks to be able to run NUnit as explained in the three following tutorials:
Using NUnit and NCover with TFS Build
Integrate Nunit test into a Tfs build
MSBuild with NUnit
The easiest way is to use the MSBuild Community Tasks where you already have a NUnit task ready to be used and you only will need to add a target to your msbuild file like so:
<Target Name="RunTests">
<!-- Run Unit tests -->
<CreateItem Include="$(OutDir)*.Tests.dll">
<Output TaskParameter="Include" ItemName="TestAssembly" />
</CreateItem>
<NUnit ToolPath="..\Tools\NUnit" DisableShadowCopy="true" Assemblies="#(TestAssembly)" />
</Target>
Related
I want to build the code using MSbuild Script in Jenkins. My code repository is on Visual Studio Online. The below script does not copy anything in the output folder on my local machine. Whereas if I am using the same script on my local machine it works fine. Below is the script I am using for my build:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<BuildArtifactsDir Include="D:\Jenkins\jobs\Test\workspace\BuildArtifacts\"/>
<TeamFoundationServerUrl Include="https://XXX.visualstudio.com/DefaultCollection/XXX-XXX/"/>
<SolutionFile Include="$(TeamFoundationServerUrl)*.sln"/>
</ItemGroup>
<PropertyGroup>
<Configuration Condition="'$(Configuration)'=='' ">Release</Configuration>
<BuildPlatForm Condition="'$(BuildPlatForm)'=='' ">Any CPU</BuildPlatForm>
</PropertyGroup>
<Target Name="Compile" DependsOnTargets="Init">
<MSBuild Projects="#(SolutionFile)" Targets="Rebuild"
Properties="OutDir=%(BuildArtifactsDir.FullPath);Configuration=$(Configuration);Platform=$(BuildPlatform)"/>
</Target>
<Target Name="Init">
<MakeDir Directories="#(BuildArtifactsDir)"/>
</Target>
My Environment:
Jenkins: On my local host.
MSBuild Plugin in Jenkins.
Visual Studio Online for Code repository.
You cannot get the solution from VSO/TFS via msbuild directly.
To connect to VSO/TFS server from Jenkins, you can install TFS Plug-in in your Jenkins server via "Manage Jenkins -> Manage Plugins -> Available -> Team Foundation Server Plug-in". And then configure your project like following:
The plug-in will get the latest solution from your VSO/TFS server and copy it to your Jenkins server, you can then update your msbuild script accordingly.
Please note that you need to use "Alternate authentication credentials" to log in VSO/TFS server with this plug-in. To enable this feature, sign in your VSO/TFS account, enable it under "My Profile/Security/Alternate authentication credentials".
I'm a complete novice in using TFS Build definition and MSBuild scripts.
I want to automate my SSIS build and deployments and create a build definition which will build and deploy my SSIS project whenever I queue it up.
I found this project: http://sqlsrvintegrationsrv.codeplex.com/releases/view/82369
which allows you to create a DLL which you can place in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies
Then you can call the SSIS.MSBuild.proj (See end for this) with certain parameters like this in a visual studio command line:
MSBuild SSIS.MSBuild.proj /t:SSISBuild,SSISDeploy /p:SSISProj="MySSISProject",Configuration="DEV",,SSISServer="AB-CDE-FGH-I1\DEV",ProjectName="MySSISProject"
or I can put it in a BAT file like this:
%systemroot%\Microsoft.Net\Framework\v4.0.30319\MSBuild.exe SSIS.MSBuild.proj /t:SSISBuild,SSISDeploy /p:SSISProj="MySSISProject",Configuration="DEV",,SSISServer="AB-CDE-FGH-I1\DEV",ProjectName="MySSISProject"
It works fine when you run the BAT file, it builds and deploys the SSIS project.
Questions:
How can I use this so it is automated, so I can manually kick off a build and deployment from within VS/TFS? Using a build definition.
How can I ensure the correct configurations are selected, and the correct destination server? For example we have SSIS configurations for DEV, SIT, SYS, UAT, PRD. Each with its own server name. Do I need a separate build definition for each environment or is there a way to use one build definition?
Anything useful in using powershell somehow?
Here is SSIS.MSBuild.proj:
<?xml version="1.0" encoding="Windows-1252"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="SSISBuild;SSISDeploy">
<!--Requires a property called $(SSISProj) to be defined when this script is called-->
<UsingTask TaskName="DeploymentFileCompilerTask" AssemblyFile="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.SqlServer.IntegrationServices.Build.dll" />
<Target Name="SSISBuild" Condition="'$(SSISProj)' != ''">
<PropertyGroup>
<SSISProjPath>$(SSISProj)\$(SSISProj).dtproj</SSISProjPath>
</PropertyGroup>
<Message Text="**************Building SSIS project: $(SSISProjPath) for configuration: $(CONFIGURATION)**************" />
<DeploymentFileCompilerTask
InputProject="$(SSISProjPath)"
Configuration="$(CONFIGURATION)"
ProtectionLevel="DontSaveSensitive">
</DeploymentFileCompilerTask>
</Target>
<UsingTask TaskName="DeployProjectToCatalogTask" AssemblyFile="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.SqlServer.IntegrationServices.Build.dll" />
<Target Name="SSISDeploy" Condition="'$(SSISProj)' != ''">
<Message Text="**************Publishing SSIS project: $(SSISProj) to: $(SSISServer) to folder: $(PROJECTNAME)**************" />
<PropertyGroup>
<ISPac>$(SSISProj)\bin\$(CONFIGURATION)\$(SSISProj).ispac</ISPac>
</PropertyGroup>
<DeployProjectToCatalogTask
DeploymentFile="$(ISPac)"
Instance="$(SSISServer)"
Folder="$(PROJECTNAME)"
CreateFolder="true"/>
</Target>
</Project>
EDIT I tried adding some MSBuild Arguments to the TFS Build Definition. I tried various combinations of arguments, some with quotes, some without. I couldn't get it to work.
"C:\Users\me\Desktop\Buildssis\SSIS.MSBuild.proj" /t:SSISBuild,SSISDeploy /p:SSISProj="MySSISProject",Configuration="SIT",SSISServer="AB-CDE-FGH-I1\DEV",ProjectName="MySSISProject"
But I always get this error:
MSBUILD : error MSB1008: Only one project can be specified.
Switch: C:\Users\me\Desktop\Buildssis\SSIS.MSBuild.proj
For switch syntax, type "MSBuild /help"
I think you are prety close about the solution. you can call your package in console application and set the variables there. And for different DEV, SIT, SYS, UAT, PRD. you can have configuration file for the the console application. and then you can set the package variables in the console app. I hope it solve the preoblem. As much i could understand.
Please let me know if this is not related to your problem then explain your question a bit more.
To answer your question, the best way would be to use an UpgradeBuildTemplate for your team build.
Modify the build script to calls the tasks that you have created in the "AfterCompile" target of the build. See below
http://msdn.microsoft.com/en-us/library/aa337604(v=vs.100).aspx
You can pass build parameters in your team build definition. If you edit your build definition and edit Process, you will see option to pass MSBuild Arguments.
I have I multilanguage project using Java, C#, C++. And I using ant script for building and running test.
Currently, I exec msbuild from ant script and redirect the msbuild output to log files. If build fails on msbuild (.net) compilation errors I should go to Artifacts and look for log file and search error in this file. I want to see all compilation error on overview tab of TeamCity build (both java and .net).
Teamcity has MSBuild Task for NAnt out of the box, but has no support for MSBuild on Ant. Of course I can split all build process in 2 parts: Ant script for Java ant NAnt for .NET, but it's undesirable.
So, what is the best way to get msbuild (compilation) errors on teamcity build page in case of msbuild is called from Ant build script.
I found answer in this topoc: How to get TeamCity to recognize msbuild compilation errors, using the Rake runner. I need to run msbuild like this:
msbuild /l:JetBrains.BuildServer.MSBuildLoggers.MSBuildLogger, path to dll
Is there any tutorial to show how can I use MSBuild tasks like FtpUploadDirectoryContent to copy file/directory to a remote host using FTP in Team Build 2010? I never used a MSBuild task in TFS 2010.
Just put it in the AfterBuild target of one of your projects - probably best to put it in the project that's at the top of your dependency graph. You can add a condition if you don't want it to run in Visual Studio, or if you only want to do the FTP transfer for a particular build configuration. For example:
<Project>
...
<Target Name="AfterBuild" Condition="'$(BuildingInsideVisualStudio)'!='true'" >
<!-- Insert your FTP task here -->
</Target>
</Project>
See How to: Extend the Visual Studio Build Process
You might consider modifying your build process template (WF) and using the InvokeProcess activity call out to FTP.exe.
There are also a handful of FTP activities and command line utilties if the built in Windows FTP command line client doesn't work for you.
has anyone got NCover, TypeMock and MSTest to work together? and if so how.
I've had 2 or 3 serious tries at this now and just can't get it to work.
I'm using MSTest 9, NCover 2.1 and TypeMock 4.1.
Ideally I would like to run them from an MSBuild task.
Cheers
Mat
Well its a bit late but here is the answer for future generations ...
Few key points:
In older version of Typemock (like 4.1) you need an enterprise license in order to run Typemock with NCover. In the current version all licenses have the same features list.
In order to run Typemock with other profilers you need to use the link feature of Typemock. In your case you can do it with Typemock MSBuild task.
You need to run MSTest with the /noisolation argument. This will prevent MSTest to spawn VSTestHost.exe process that will actually run your tests. This creates a problem enabling the environment variables that are needed in order to let the profilers work
In the example below I'm running the tests in Tests.dll and asking for coverage report about ClassLibrary.dll
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="RunTests" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project ="c:\Program Files\Typemock\Isolator\5.2\TypeMock.MSBuild.Tasks" />
<PropertyGroup>
<NCOVER>"E:\src\TypeMock\Build\Binaries\NCover\NCover 2.0\NCover.Console.exe"</NCOVER>
<MSTest>"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe"</MSTest>
</PropertyGroup>
<Target Name ="Test">
<TypeMockStart Target="2.0" Link ="NCover2.0"/>
<Exec ContinueOnError="true" Command="$(NCOVER) //a ClassLibrary $(MSTest) /noisolation /testcontainer:E:\src\TestNcover3\MSBuildTest\bin\Debug\Tests.dll" />
<TypeMockStop/>
</Target>
</Project>