Dynamic number of MSBuild tasks - cruisecontrol.net

In CC project config file I have many MSBuild tasks. Each task is used to build one solution.
Problem is that this requires maintenance if this CC config file each time when new project is added to / deleted from repository.
My idea is to pass to the CC dynamic list of solutions that should be build and execute build one by one as it is done now with "static / old fashion" maintenance of config file.
Does anyone prepare already such configuration?

Presuming you have something akin to the following:
On disk:
./solution1.sln
./solution2.sln
./solutionN.sln
And a single ccnet project:
Msbuild task -> solution1.sln
Msbuild task -> solution1.sln
Msbuild task -> solutionN.sln
What you are asking for is ccnet to react to what is outside of its environment. This isn't possible, however it would be possible to get another tool to do so.
Possible options:
1. Custom Msbuild project
Create a specific msbuild project which finds and invokes msbuild on all solution files it finds. Call msbuild on this project alone. It should be possible to do this with vanilla msbuild, see https://msdn.microsoft.com/en-us/library/z7f65y0d.aspx
2. Batch files
Find all files, and for each file execute msbuild. Ensure the output is logged to an XML file (msbuild switch - I believe) and merge in the result in the publishers section.
See How to do something to each file in a directory with a batch script
3. Single solution
Create a single solution, which contains all the projects from all solutions (1 to N) and call msbuild on this once.
This solution file would be need to be updated each time a new project comes along however.

Related

Visual Studio Team Services - Release Management cannot locate tests

When using the Visual Studio Test task in Release Management, the release always returns:
No test assemblies found matching the pattern
currently Test Assembly is set to: **\*test*.dll;-:**\obj\**
I have tried multiple defaults like $(System.DefaultWorkingDirectory), etc.
The documentation I've been able to find is either not current with the existing layout of tasks, (such as the Publish Build Artifacts screen no longer containing the Contents box), is for the on premise Visual Studio 2015, or related specifically to the Build.
I've read and attempted the following:
https://msdn.microsoft.com/Library/vs/alm/Release/getting-started/deploy-to-azure
https://msdn.microsoft.com/Library/vs/alm/Release/author-release-definition/understanding-tasks
https://msdn.microsoft.com/en-us/library/gg265783.aspx#Activity_RunTests
http://blogs.msdn.com/b/visualstudioalm/archive/2015/07/31/dev-test-in-azure-and-deploy-to-production-on-premises.aspx
http://blogs.msdn.com/b/visualstudioalm/archive/2015/05/29/testing-in-continuous-integration-and-continuous-deployment-workflows.aspx
UPDATE:
I added a step to the build to Copy and Publish the test.dlls. They are now located. They all fail, due to missing other code, but they are located.
UPDATE II:
My 3_Run_Tests.log file contains the following clues:
Error calling Initialization method for test class ... To run tests that interact with the desktop, you must set up the test agent to run as an interactive process.
Test Run deployment issue: The assembly or module ... directly or indirectly referenced by the test container ... was not found.
Because of the above, I am going to accept #eddie-msft's answer.
You need to make sure that the complied file of the project which you'd like to test is also been copied and published to the same path with Test Assembly. The test will fail if only Test Assembly is copied.
I assume you are working on a C# project, in the step to copy test assembly, you can set the copy content as this:
**\YourTestProjectName\bin\$(BuildConfiguration)
I have been having a similar issue. Multiple projects in build and the test file would not be found.
No test assemblies found matching the pattern *test*.dll;-:\obj**
Fix: added additional build step "build solution" and "Copy Files to". This build was pointed to VS solution file with automated test. "Copy Files to" was left at default

CruiseControl with static website?

I maintain a classic asp web application, and I'd like to try to automate some of the merging to and from branches using CruiseControl (CruiseControl.net specifically). But I don't have any use for a build tool. Basically I would want a commit on /trunk to automagically get merged to a bunch of feature branches that would exist as CC projects.
Is this possible/recommended or is there an easier way to do this?
Some parts of the repository do contain VB6 or .NET code, so I would like to be able to automate builds to those parts in the future, but for the time being I would just basically be using it to automate keeping my static website clean.
It is not the normal responsibility of CruiseControl to affect source control, short of tagging commits. You could have another, say release, branch that CruiseControl monitors. The merging can then be done manually to this branch as required - resolving any merge conflicts at point of merge. CruiseControl would then just 'build' these merge commits.
CruiseControl is a basically a tool for executing commands in a given order based on a trigger. In your case a SourceControlTrigger.
You can setup CruiseControl to execute msbuild, or not, as required.
As you are trying to deploy/package a classic asp site, I guess you only need to copy/zip the source files and deploy them to your web server. This can be achieved as so:
Use nant to copy, and zip, your source files, execute it via an nant task
use curl, executed via an exec task to send the zip file via http(s)
If required you can preceded this with an msbuild task to build your .net projects.

Separate TFS Build excluding a single project

I have a solution that currently builds nicely in TFS. I have just added a Sandcastle help File Builder project to it so that the help files can be generated. Now the solutions takes ages to build locally (it has also doubled the build time on the TFS Server).
In practice I'd be happy generating the help files once per day, or only when specifically requested as part of a build.
I tried creating a separate solution (for a new build) which included the Sandcastle project but I got a warning saying that the projects were already under source control.
What is the best way to configure TFS/the solution for this sort of situation? Can I have two builds that run on separate schedules and include/exclude certain projects in the solution?
You can create a new solution configuration that excludes building your help project. Then in your TFS build you can specify which configuration to build. You could have a CI build that doesn't include your help project, and then a nightly build that includes everything.

Specify which Publish script to use on build?

How do I have SSDT run my publish script when I build my solution file?
If you:
1) Right click on your solution
2) Click Configration Properties
3) Click Configuration
I can see the database project and where it is checked to deploy on build, it does not let me specify what publish script to use.
As far as I know this isn't possible out of the box.
Why? They are two very different things.
Building (if you were to think of it as code) compiles and checks, producing artefacts. For .NET code those artefacts are DLL's/.exe etc. For .sqlproj it's the .dacpac etc that turn up in /sql/[Build Configuration Name].
Publishing is akin to Deploying if you were talking .NET code. Building won't include Publishing as an action.
Ironically, a Publish action also Builds the solution, so my suggestion would instead be to consider one of the following:
Publish the project (right click Publish, or double click your chosen .publish.xml file) whenever you want to build.
Use the Post-Build command line in the project Properties to call sqlpackage.exe to deploy your newly compiled .dacpac with your specified .publish.xml profile - but note that this will also impact your use of the Publish action from within Visual Studio as a Publish builds and then publishes (so you'd end up publishing twice).
Depending on your comfort levels/if you are a command-line fan, then use the command line (bash file? Powershell?) to call msbuild followed by sqlpackage.exe. Whenever you want to build, run your command in cmd.exe.
Similar to #3, add a menu item to the Tools menu that would do exactly the same thing (msbuild followed by sqlpackage deployment) but from within Visual Studio itself.
Look at a Continuous Integration model (TFS/TeamCity/Bamboo/Jenkins and about 3000-others), which could build and deploy for you automatically with every change - either on another server, or running locally (I put this in without knowing your scenario, so may be very much unsuitable to solve your problem).

CruiseControl / NANT <copy> Task

We have a website with all the media (css/images) stored in a media folder. The media folder and it's 95 subdirectories contain about 400 total files. We have a Cruiscontrol project that monitors just the media directory for changes and when triggered copies those files to our integration server.
Unfortunately, our integration server is at a remote location and so even when copying 2-3 files the NANT task is taking 4+ minutes. I believe the combination of the sheer number or directories/files and our network latency is causing the NANT task to run slow. I believe it is comparing the modified dates of both the local and remote copy of every file.
I really want to speed this up and my initial thought was instead of trying to copy the whole media folder, can I get the list of file modifications from CruiseControl and specifically copy those files instead, saving the NANT task the work of having to compare them all for changes.
Is there a way to do what I am asking or is there a better way to accomplish the same performance gains?
This sounds like a job for RoboCopy. Use NAnt to bootstrap the execution and let RC do the file synchronization.
Update: digging deeper into the CCNet documentation you'll find the <modificationWriter/> task. Adding this task to your ccnet project will write out an xml file containing information about all the modifications. You should be able to read in the contents of that file in your NAnt script. A suggestion here is to use the NAnt <style/> task to convert the modification xml into a NAnt script containing copy and delete tasks.

Resources