Integrating MSTest with Cruise control for multiple projects - mstest

I have integrated MSTest with cruise control for single project by following the steps present in the below link.Its working fine
http://www.codeproject.com/KB/tips/VSTS2008_Tests_With_CCNET.aspx?display=Print.
But if i add multiple projects, the result file is getting over wrtitten by 2nd project result. I am not able to see the first project result.
Please let me know how i can display multiple project results in result fie.

... in the meantime I checked the problem in more detail and it seems that my 1st guess was right (although I didn't realize that no real build script but a simple batch is used):
Problem: A single working directory is used for all projects. Each project produces it's own results.xml file but since they are all stored in the same location results are overwritten.
Solution: Use a separate folder for the results of each project (e.g. the project's artifact directory which is passed from CruiseControl to the batch process as environment variable).
RunTests.bat:
del "%CCNetArtifactDirectory%\results.xml"
MSTest.exe /testcontainer:<PathtoTestProject>\Bin\Debug\TestAssembly.dll /resultsfile:"%CCNetArtifactDirectory%\results.xml"
ccnet.config:
<project name="ProjectA">
<cb:define projectArtifactDirectory="C:\path\to\data\of\ProjectA" />
...
<artifactDirectory>$(projectArtifactDirectory)</artifactDirectory>
...
<publishers>
<merge>
<files>
<file>$(projectArtifactDirectory)\results.xml</file>
</files>
</merge>
</publishers>
...
</project>

Related

Octopack: Additional files copied in a pre-build event

I am trying to get Octopack to include some additional dll's that are not part of my Visual Studio project.
Is there a way to get Octopack to use my csproj files (as normal) and then specify just the additional files I need, rather than using the section in the nuspec. (Because then I have to maintain a list of all project files in my nuspec)
I am currently copying some shared libraries to a folder "/providers" in a pre-build event. Is there a way to extend on this to copy them somewhere that Octopack will see and package them?
You don't need to maintain a list of all your project files in your nuspec file, you can do this:
<files>
<file src="MyProject.Website\**\*.*" target="" />
</files>
This will grab everything in your project (all files and sub directories). If that's too much for you, you can take advantage of exclusion rules:
<files>
<file src="MyProject.Website\**\*.*" target="" exclude="MyProject.Website\docs\admin.txt" />
</files>
Hope that helps.
The downside of the answer of grabbing everything inside your project directory via the nuspec is that this could include files you don't want (see the answer's subsequent exclusion example).
A probably better way to do this is to ensure in your project that you have your files defined as "Copy to bin" or "Copy as content" and then build via msbuild w/Octopack using an additional command line argument of /p:OctoPackEnforceAddingFiles=true which tells OctoPack to combine the csproj and the nuspec, so you don't have to call out ALL the possible paths with a wildcard, you can only include files in your nuspec that aren't picked up from the regular build process. This is supported as of version 2.1.3 of OctoPack.
You could also use regular Nuget.exe and MSBuild by just specifying your csproj file, and if a nuspec exists with specific paths it should join them together.
See these reference links for better examples.
https://getadigital.com/no/blogg/setting-up-your-project-and-teamcity-octopack-for-front-end-builds/
https://octopus.com/docs/packaging-applications/nuget-packages/using-octopack/octopack-to-include-buildevent-files

Continuous Integration with Jenkins: Binary Output need to be copied to a shared directory

Our .NET app with 8-10 projects and created a Jenkins job to build it.
We also have a batch job called in Jenkins to create the set up files for our app using INNO Setup. The issue we need to address is copy the Setup files to a shared location. Could you please suggest a better way to accomplish it.
In general, you will probably want to use a publishing plugin. There are different plugins depending on where (and how) you want to put the file. Here's a quick list to get you started:
Publish Over FTP Plugin - use if you want to send the output to an FTP location
Publish Over SSH Plugin - use if you want to use SSH to publish your artifacts.
Publish Over CIFS Plugin - use this if you are wanting to put stuff in a Windows (CIFS , SMB) share
A larger list can be found in the Artifact Uploader Plugins list.
In a .NET environment you should have a look at Nant (http://nant.sourceforge.net/).
Use a Nant script as a post-build action with a default.build like this :
<?xml version="1.0" encoding="UTF-8" ?>
<project name="MyProject" default="network-copy" basedir=".">
<target name="network-copy">
<copy file="target\setup.exe"
todir="\\server\share$\directory"></copy>
</target>
</project>

Fetching labeled files into a TFSBuild

I am sure there is a simple answer to this, but my google-fu fails me.
I have a team project in TFS 2008 that builds OK when using the latest code, however I now have a need to fetch the previous versions of a subset of the files at build time. The subset of files are all labeled with the same label ("MyLabel" in the snippet below).
The snippet of XML I have added to be TFSBuild.proj file looks like this:
<PropertyGroup>
<BuildLabel>LMyLabel</BuildLabel>
</PropertyGroup>
<Target Name="BeforeCompile">
<Get
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Condition=" '$(SkipGet)'!='true' "
Workspace="$(WorkspaceName)"
Recursive="$(RecursiveGet)"
Force="$(ForceGet)"
Version ="$(BuildLabel)"
Preview="false"
/>
</Target>
This successfully fetches the subset of files into the source area, however it also deletes all other files in the source area.
i.e. the build process does the following:
fetch latest versions of all files into the source area
fetch labeled version of subset of files into the source area
delete all non-labeled files from the source area
run build
The build fails with the following error:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets(997,5): error MSB3491: Could not write lines to file "[build directory]\Sources\MySolution.sln.x64.Release.vsprops". Could not find a part of the path '[build directory]\Sources\MySolution.x64.Release.vsprops'.
(which basically indicates that it can't find the solution, because it's been deleted)
I've tried adding the following snippet to the bottom of the XML:
<PropertyGroup>
<SkipClean>true</SkipClean>
<SkipInitializeWorkspace>true</SkipInitializeWorkspace>
<ForceGet>false</ForceGet>
</PropertyGroup>
</Project>
but the result is the same.
So, my question is: how do I build my solution when it is a mixture of latest versions and older, labeled versions? What am I missing?
(I realize I could just branch the baseline but for various reasons I would like to explore this approach first)
Thanks in advance!
Just a simple approach that come to mind:
Get your latest version to workspace1
Get your labeled version to workspace2
XCopy workspace1 content over workspace2 as a post-get action
What do you think? Worth the try?
Looking at C:\Program Files\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets, it appears that the version fetched for the build is controlled by the GetVersion property. And that ForceGet is true by default.
I haven't tested it, but that implies to me that if you put
/property:GetVersion=*versionspec*
in the MSBuild Command Line Arguments textbox when you queue the build, it should fetch the specified version (look here for versionspec syntax. If this fails for some reason, read Aaron Hallberg's blog until you understand msbuild better than I do:-)

Problem with CruiseControl.net configuration

I started using ccnet to build my project. This is quite new issue for me so I have some problems.
First thing: Why does ccnet copy directory with my project to another directory (ccnet creates new folder named the same as project name included in ccnet.config file and copies to them directory with my project)
Second thing: Dashboard page cannot show reports for recent build (When I click on any item in recent build then I get page: "The page Cannot be found" I suppose that page cannot link files with logs. but I don't know how to link it.
I create one publisher:
<publishers>
<xmllogger logDir="c:\Branches" />
Can anyone help me?
Just a question, does the batch file "C:\Branches\Scripts\Build Release.bat" perform that step?
Because I can't see anything obvious within the CruiseControl config to copy the files into "c:\Program Files\CruiseControl.NET\Sever\TestProject"...
In build Release script I just call devenv to compile my project
Not sure I fully understand the 'first thing' if you can elaborate on it I'll try to help.
On our system it performs an SVN checkout of the code to a specified location and builds it there. Even though our CCNet installation is on the same box as the SVN repository it still needs somewhere separate to build the project.
On the 'second thing' it sounds like you have not set the <webURL> element properly - not a major problem. If you can post your config file that may help (with both issues).
Our CCNet installation pretty much worked out of the box but it is pretty fussy about it's config files. Have you made any changes to the dashboard.config file or is it as installed?
[Edit in response to posted config file]
I can't see anything in this config that will cause CCNet to copy the project to c:\Program Files\CruiseControl.NET\Server\TestProject. It could be something to do with the way you are calling devenv in your batch file - do you specify any paths in there?
Based on your config file and assuming you have an out of the box installation, your <webURL> element should read something like this:
<webURL>http://localhost/ccnet/server/local/testProject/ViewProjectReport.aspx</webURL>
On top of all that I would highly recommend that you drop the use of .bat files and devenv.exe for building your projects. Although this is the way I started with CCNet I quickly found that using NAnt and MSBuild well worth the effort.
I Try explain it more.
I have my local copy of repository on the path: "c:\Branches\trunk"
here is my config file:
<cruiseControl>
<project name="testProject">
<webURL>http://localhost/ccnet/</webURL>
<triggers>
<intervalTrigger name="interval trigger" seconds="600" initialSeconds="30" />
</triggers>
<sourcecontrol type="svn" autoGetSource="true">
<trunkUrl>http://********/svn/general/provider/prototype/Trunk</trunkUrl>
<workingDirectory>C:\Branches\Trunk</workingDirectory>
<password>***********</password>
<username>*************</username>
</sourcecontrol>
<tasks>
<exec>
<description>Compile program</description>
<baseDirectory>C:\Branches\Trunk\</baseDirectory>
<buildTimeoutSeconds>9000</buildTimeoutSeconds>
<executable>C:\Branches\Scripts\Build Release.bat</executable>
</exec>
</tasks>
<publishers>
<xmllogger logDir="C:\Branches\Trunk\Logs" />
</publishers>
<state type="state" directory="C:\Branches\Trunk\Logs"></state>
</project>
</cruisecontrol>
I didn't change anything in dashboard.config File.
cnet copy all folder c:\Branches\Trunk
to new folder c:\Program Files\CruiseControl.NET\Sever\TestProject
First problem was cause because in previous version of config file i use filesystem as sourcecontrol. Right now this problem don't occur.
Second problem is not resolved, But I have one Idea, Does any configuration files should be placed in virtual directory?

Project file with just files and no built output

How can I make a project file (VS 2008) that just has some data files in and has no built output?
I can make an empty project and add my data files to it (which get copied to the output folder
), but it produces an EmptyProject.dll after I do a build. I want just my data files in the output directory and not some empty DLL or EXE.
I want the data files to be the only thing in this project as the project will be shared in a couple of solutions.
Our application is C#. All of our normal code projects are C#.
The data files are schemas (XSD). I want these schemas to be in the output folder, but I don't want them included with an existing project. I would like a project named "Schemas" that has nothing in except the XSD files and does nothing except copy the XSD files to the output folder. I would like this in a project file so that the same schemas project can be referenced in multiple solutions.
I don't know of a way to suppress the creation of the .dll file. BUT... here's an easy workaround. In the project properties, Build Events tab, write a Post-build event command line that will delete the file. Something like:
del path\filename.dll
Expanding on Scott's answer:
Create a new project of type Empty project
In Properties->Application, change Output type to Class Library
In Properties->Build->Advanced, change Debug Info to None
In Properties->Build Events, set the Post-build event command line to del $(TargetPath)
That way, the project creates only a DLL, which gets deleted. At the same time, the "copy to output directory" settings on your data files is respected.
Possibly another way is editing the csproj file by replacing this:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
with this:
<Target Name="Build" />
<Target Name="Rebuild" />
Then builds don't create anything. It worked for me.
Same general idea should work for any xxproj file. Just replace the <Import Project...> tags with the <Target...> tags.
I'd be interested in knowing if this causes any issues or doesn't work for anyone.
What do you need a project for if you're not building it?
You can use solution folders to "store" files...
Why not just disable building this project for all configurations (use the Configuration Manager) - that way it won't build.
Great stuff. Expanding on Scott > Daniel's answer:
Safe to remove all References and Properties (AssemblyInfo.cs)
If it is a node/grunt/gulp project then you can invoke it in your Build Events > *Post-build event command line * eg: gulp build or gulp clean
Perhaps you can add removal or obj and bin output folders to your node/grunt/gulp clean scripts mitigating the need for del $(TargetPath)

Resources