Using TFS Build to Deploy Console Application with Continuous Integration - deployment

I have a solution that contains a number of projects. Some MVC Web Applications, Some Class Libraries and some Console Applications.
For the Web Applications we simply used Publish Profiles and created TFS Builds referring to those profiles for building deployment packages. We then used those to deploy the web apps.
How can I configure the Build Definition to give me the same results for my console applications?
The desired result here is to try and work towards automatic deployments using TFS and Release Management.
Update:
Ok, It seems I need to explain myself better.
We use TFS (MSBuild) to build the project. By simply "checking in" the code, it triggers our build which builds the project and creates a nice Website_Package.zip file in the drop folder.
What I am looking for, is for MSBuild to do the same for my Console Application. ie. I want it to produce a "ConsoleApp_Package.zip" file and dump it into my drop folder.

You can use the Zip task from MSBuild Extension Pack at http://msbuildextensionpack.codeplex.com/.
See http://www.msbuildextensionpack.com/help/4.0.8.0/index.html for an example.

You should just build, using MSBuild task, filling the Project with your console app .csproj and leave MSBuild Arguments empty.
Then you use a Copy Files task to get your files from bin folder to staging directory.
Example:
Source Folder: \bin\$(BuildConfiguration)
Contents: **
Target Folder: $(Build.ArtifactStagingDirectory)
After that you can add task to zip the files from staging directory.

Related

Prevent a VS solution's project from being built by Appveyor

The .sln file in my GitHub repository has two projects -- a class library project, and a tests project. I only want AppVeyor to build the library project, because the tests project requires the Microsoft Access database engine to be installed.
I am using appveyor.yaml.
How can I do this?
You could switch from automatic msbuild mode to script mode, by adding a build_script section to your yaml config file. This might look something like this...
build_script:
- msbuild StringAsSql/StringAsSql.csproj /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
It's the same command AppVeyor would run automatically on your solution file.
There are a number of possible options here.
To disable tests, set the following in appveyor.yml:
tests: off
Or create a special build configuration (via the Visual Studio Configuration Manager...), say ReleaseCI, and specify the configuration in appveyor.yml:
configuration: ReleaseCI
Another option is to create multiple solution files; the UI for switching solutions is simpler (Solution Explorer -> Switch views...) than the UI for switching build configurations. To specify which .sln file should be passed to MSBuild:
build:
project: MySolution.sln

TeamCity nuget pack step missing files when packaged

Our first step is a MsBuild for our .sln file. We pass in our platform and config and everything is built correctly.
Next we want to NuGet pack all the files for Octopus Deploy to use. In this step we specify all of our .csproj files (not sure why, everything is already built)
The package that is created contains 2 folders, Content which contains all the files needed minus bin and the Lib folder which contains only the projects compiled dlls. It's not including any of the other dlls referenced in the project.
It sounds like it might be easier for you to use Octopack to handle the creation of the NuGet packages to be deployed.
Step 1. Install the Octopack NuGet package into the projects that are your deployable applications.
Install-Package OctoPack
Step 2. Ensure you have a build step before the main compilation that will install any referenced NuGet packages.
Step 3. Install the TeamCity plugin for Octopus deploy from the downloads page and restart the TeamCity server service
Step 4. You'll now see additional options in your MSBuild runner configuration and if you check the following box in your build configurations, it will produce a NuGet package for you which should have everything required for a successful deployment.
As a small tip, I publish the package straight to Octopus by referencing the output package (rather than waiting for it to be attached as an artifact at the end of the build and thus requiring two build configurations)
Hope this helps
If NuGet pack is not packaging your application as you expected from your project file, you have to create a NuGet spec file and specify how things should be packaged. For a web application that is as simple as creating a simple .spec file and putting it into your web application directory, but for other projects that can be a little more complicated. Check out the Nuspec Reference to see how to add your content and dependencies. https://docs.nuget.org/create/nuspec-reference

CruiseControl.NET NuGet not working

My CruiseControl.NET build server is not able to restore the nuget packages of my projects. According to some websites it should be enough to set the environment variable EnableNuGetPackageRestore to "true" and restarted Cruise Control after that, but that didn't help in my case.
What else can I do?
Do i need to install something that "enables" Nuget?
I noticed I have a .nuget folder in C:\Users\MyUser\ but I don't have this folder on the build server. Is this required? Who created that on my pc? Visual Studio?
Without seeing the project config, I am assuming you are using either a Microsoft Solution or project, and are building from that using the msbuild task in CC.net. If so, your Solution needs a .nuget folder structure (in the same location as the sln/prj file there needs to be a .nuget folder, inside that folder, you need a NuGet.Config and a NuGet.exe as well as a NuGet.targets).
This should be automatically added to your solution if you right click on it inside visual studio and select "Enable nuget Package Restore".
You can find more information # Nuget Documentation. There is quite a few ways to skin this cat, but, based on your initial statement, you are just missing the .nuget folder in your Solution, and once added it should just work. Otherwise, you have to look at pre-build tasks, and that gets a little more detailed than is usually necessary.

automatic build and deploy fails with build failure on jazzhub

I am trying to use the feature of jazzhub (IBM DevOps offerings) of automatically build and deploy on Bluemix. I have used Eclipse plugin for Jazzhub to check in my code to my project. However automatic build always fails with the below type of error.
using .gitcredentials to set credentials
Checking out Revision a0b1e7c78b02e82ad210bc369cdd633212cb544f (origin/master)
First time build. Skipping changelog.
[47f4a135-016e-4a75-bb42-f9a9fda6df05] $ /bin/bash /tmp/hudson3124921405781328608.sh
Buildfile: build.xml does not exist!
Build failed
Build step 'Execute shell' marked build as failure
Connecting to https://P90JEN01.sl.jazz.net:9444*
I am able to build and deploy the same code base from Eclipse directly to bluemix. My understanding is that DevOps service create build.xml file automatically if It does not find one. The document says it
"A project relative path where the build scripts are found and executed. The project root will be used if empty. A default build script (e.g., Ant build.xml file or Grunt Gruntfile.js file) will be generated and delivered to your source control system if one is not found. You may need to edit the generated build script to fit your needs".
Can anyone help me here? how to get pass this error and make a build successfully deployed ?
I believe we may need to create build.xml if you are using ant script:
http://thoughtsoncloud.com/2014/10/create-deploy-stand-alone-java-application-ibm-bluemix/
"The next step is to create the script to build the code. In this example, I created an .ant script. You can write in the language of your choice from the options supported in Bluemix. Create a file named build.xml and write the .ant build script."

ScriptSharp compilation with NAnt script

We've recently added the excellent script# to our project. Currently we have it so that our VS build simply copies the compiled .js file from the output directory to the scripts directory of our web app.
We've decided to make it a permanent feature and so would like to make it so that the .js file gets generated as part of our web build NAnt script to ensure that it's always up to date. Is there any way to do this nicely or do I need to call MSBuild from my NAnt script specifying the .csproj file to run the compilation?
Thanks
Stu
This isn't likely the full answer (given I don't have experience with NAnt), but I'll offer it anyway, as it may help.
A script# csproj is very much like any other csproj relying on msbuild. If you've got some way to integrate other msbuild projects into your NAnt build script, the same model should ideally apply to script# projects as well.
In the version of script# that is in the github repository, a web project can add a reference to a script# project (thereby becoming dependent on the script# project), and include an msbuild deploy task, that will copy over scripts from the built script# project into the web project. You can see this in action in the Todo sample (https://github.com/nikhilk/scriptsharp/tree/cc/samples/Todo)