Sponsors

News

Jobping Laurent Kempé MVP JetBrains Academy Member Certified ScrumMaster

Contact

My status

View Laurent Kempé's profile on LinkedIn
XING
twitter
facebook


Xbox 360



Map

Locations of visitors to this page

.NET Dudes

Family

French .NET Dudes

Friends

Jobping

Links

Tech Head Brothers

October 2009 - Posts

Build ClickOnce deployment packages using MSBuild and Team City

The other day I was requested to automate our build process to issue different ClickOnce setup for the same application. The main difference was some configuration files pointing to different back end web services.

To start I had to create new build configurations on Team City which used the following settings for the Build Runner:

  1. Targets: Rebuild Publish
  2. Configuration: One per build configurations; e.g DeployClickOnce, integrationDeployClickOnce

Targets and Configuration

Then in my Visual Studio 2008 solution I created several Solution configuration reflecting the different configurations that I needed during my deployment, e.g. DeployClickOnce

Visual Studio 2008 solutions

Then using the project properties from the solution explorer in Visual Studio I had to set all Publish options I was interested in; Publish Location, Installation Folder Url, Install Mode and Settings, Prerequisites…

4048988539_2a9f77285f_o[1]

The issue now is that the Publish Version automatically increment the revision with each publish. But this doesn’t work with our continuous integration server Team City as it would need to checkin the modified file back to subversion. SO a different approach was needed.

The solution I used is to use the Build Number offered by Team City, so I had to modify the MSBuild script to use the the BUILD_NUMBER. To do that, right click in the Solution Explorer on our project and select Edit Project File:

4049748852_2ea06972ca_o[1]

Then you will face the your MSBuild script, and you will have to search for the configuration that we defined some steps before:

  1. <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DeployClickOnce|AnyCPU' ">

Then before the end of the closing PropertyGroupd tag add the following lines:

  1.   <!-- ClickOnce getting build number from Team City -->
  2.   <ApplicationRevision>$(BUILD_NUMBER)</ApplicationRevision>
  3.   <InstallUrl>http://myserver.com/</InstallUrl>
  4. </PropertyGroup>

ApplicationRevision will overwrite the Application revision using the BUILD_NUMBER defined by Team City.

InstallUrl is another configuration that we want to override because we want to create multiple ClickOnce setup installed from different urls. So for DeployClickOnce you will have an InstallURL and for integrationDeployClickOnce you will have another one.

Now we are ready for the final step in which we want to exchange some configuration files related to the different ClickOnce builds and Publish the output to an IIS server so that our testers can access the different ClickOnce package for the different stages.

ClickOnce secure the different files that are created with checksums so that they cannot be mitigated during the installment transfer. So the only option we have to be able to exchange our configuration files is before compilation. So we had a Target to our MSBuild script:

  1. <Target Name="BeforeCompile">
  2.   <CallTarget Targets="ExchangeDefaultSettings" ContinueOnError="false" />
  3.   <CallTarget Targets="ExchangeAppConfig" ContinueOnError="false" />
  4. </Target>

The BeforeCompile target will be called before each build and will exchange our App.config and another settings file containing stage dependant configuration.

Here is the simple target which exchanges the App.config stored in a configs folder:

  1. <Target Name="ExchangeAppConfig">
  2.   <Message Text="####### CONFIG Exchange $(Configuration)|$(Platform)  ---------#" />
  3.   <Copy Condition=" '$(Configuration)' == 'DeployClickOnce' "
  4.         SourceFiles="$(SolutionFolder)\Sources\Application\configs\localhost.App.config"
  5.         DestinationFiles="$(SolutionFolder)\Sources\Application\App.config"
  6.         ContinueOnError="false" />
  7.   <Copy Condition=" '$(Configuration)' == 'integrationDeployClickOnce' "
  8.         SourceFiles="$(SolutionFolder)\Sources\Application\configs\integration.App.config"
  9.         DestinationFiles="$(SolutionFolder)\Sources\Application\App.config"
  10.         ContinueOnError="false" />
  11. </Target>

The ExchangeDefaultSettings Target works the same.

So before any compilation of our solution using the DeployClickOnce, integrationDeployClickOnce solution configuration the App.config and the default settings file are exchanged. So after the compilation they will be correct according to the stage that we target.

The final step is to Publish the ClickOnce package created to the IIS server. As we defined the Targets: Rebuild Publish, there will be a Rebuild and then a Publish phase in our build script. So now we have to take care of the Publish target.

So we add a Target Publish as here:

  1. <Target Name="Publish">
  2.   <CallTarget Condition=" '$(Configuration)' == 'DeployClickOnce' "
  3.               Targets="DeployClickOnce"
  4.               ContinueOnError="false" />
  5.   <CallTarget Condition=" '$(Configuration)' == 'integrationDeployClickOnce' "
  6.               Targets="DeployClickOnce"
  7.               ContinueOnError="false" />
  8. </Target>

Which just call a Target DeployClickOnce for the configuration we are interested in: DeployClickOnce and integrationDeployClickOnce.

The DeployClickOnce Target is responsible to xcopy the packages created by the Publish Target to the different IIS path used to host our ClickOnce deployment setup:

  1. <!-- Deploy Click Once-->
  2. <Target Name="DeployClickOnce">
  3.   <Message Text="####### Deploy ClickOnce $(Configuration)|$(Platform)  ---------#" />
  4.   <Exec Command="xcopy /E /Y $(ClickOnceSrc)\*.* $(ClickOnceDestination)" />
  5. </Target>

This is achieved by using two variables ClickOnceSrc and ClickOnceDestination which are also defined per solution configuration like the ApplicationUrl and InstallUrl. The destination is a folder on a IIS server which already has a manually customized Publish.htm file.

  1. <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DeployClickOnce|AnyCPU' ">
  2.   <ClickOnceSrc>$(TestsFolder)\Output\$(OutputPath)app.publish</ClickOnceSrc>
  3.   <ClickOnceDestination>E:\Inetpub\Application</ClickOnceDestination>

And

  1. <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'integrationDeployClickOnce|AnyCPU' ">
  2.   <ClickOnceSrc>$(TestsFolder)\Output\$(OutputPath)app.publish</ClickOnceSrc>
  3.   <ClickOnceDestination>E:\Inetpub\Application\integration</ClickOnceDestination>

Now you have two build configurations which output two valid ClickOnce setup packages using different stage dependant configurations that your tester can install directly from your ClickOnce web site. And if you have configured the automatic update of the application through the ClickOnce Application Updates then the applciation will be updated automatically when a tester start you application.

Enjoy!

Posted: Oct 27 2009, 01:25 PM by lkempe | with 1 comment(s)
Filed under: ,
Daily stand up meeting using Skype

Today at Innoveo Solutions we had our daily Stand Up meeting using Skype as I am at home. It worked really good ! I can’t wait to experience it on the new plasma TV that we have in our meeting room!

4028288873_799bc9aef2_o[1]

And a Chicken entering the meeting ! Hey Bojan :-)

4029051070_a90ca3a4e8_o[1]

MVVM Light Toolkit V2

At Innoveo Solutions we are using .NET and WPF for our Innoveo Skye® Editor application. Skye® Editor is a distribution channel editor targeting business people letting them edit and configure their insurance products.

From the beginning we have adopted the Model-View-ViewModel architecture. Having our solution growing we were facing the issue of having our ViewModels dependency growing too. Some ViewModel became too much dependent of others. This was obvious in our unit tests whose complexity to setup were growing too. It was time to find a solution to decouple the ViewModels.

The solution came out after a discussion with Laurent Bugnion, the famous author of MVVM Light Toolkit. At that time we used the V1 that already helped a lot in this decoupling.

Now with MVVM Light Toolkit V2 it is even better with the new Messenger API. What we also really appreciated in comparison to other frameworks is that it is really light and the ability to open and edit the user interface into Expression Blend.

So Thank you Laurent for this GREAT framework and I looking forward for V3!

I also would like to thank my managers at Innoveo Solutions who understand Open Source and the need to have people contributing to Open Source projects, even during their professional working time. A Win-Win situation and not just a one way benefit as often.

ReSharper 5.0 Overview

As part of the Jetbrains Academy I am using/testing ReSharper 5 for around a month now. It is quite stable for a pre-release and I have lots of fun using it, and as always a productivity boost. Some of my preferred features are: External Sources, ASP.NET MVC integration, Solution-Wide Warnings and Suggestions, Upgrade-to-LINQ Actions. Till now I wasn’t able to test the Native NUnit Support, but this is definitely something I will test in the near future.

Jetbrains just posted on their blog ReSharper 5.0 Overview, check it out:

As promised, we’re publishing general ReSharper 5.0 overview, elaborating on its feature set in more detail.

Please keep in mind that this is a preliminary document. The general picture will stay unchanged but local amendments can not be ruled out at this point, and many user interface items will probably change.

Features
  • External Sources
    A solution is not limited to sources included in your projects, but it also contains sources that were used to build your libraries. Some companies publish parts of their sources using the Source Server feature of debug information files (PDB). This is the same technology that Microsoft uses to provide access to source code for parts of .NET Framework. With ReSharper 5, you can now access it as if it were a part of your solution. When no sources are available, ReSharper does a decent job of reconstructing types’ structure from metadata for your browsing pleasure.
  • Structured Patterns
    “I was assigned to new project, and the source code is full of [your favorite code smell here]. Please, make ReSharper analyze and fix it!”. Fortunately, ReSharper 5 can address this demand. You can set up your own code patterns, search for them, replace them, include them into code analysis, and even use quick fixes to replace! Building patterns and enforcing good practices has never been easier. Corporate and team policies, your own frameworks, favorite open source libraries and tools — you can cover them all.
  • Project Refactorings and Dependencies View
    Once you are used to smart, automated refactorings provided by ReSharper, you can’t think of executing them manually anymore. In this release, we extend ReSharper’s coverage to bring you several refactorings for project structure. With ReSharper 5, you can move files and folders between projects, synchronize namespaces to folder structure in any scope as large as solution, safely delete obsolete subsystems without going type by type, and split a file with lots of types created from usages into their own dedicated files in one go. We have also added special project dependencies view to help you track down excessive dependencies between projects and eliminate them. As an early ReSharper 5 user said, “I no longer feel fear to restructure my project. I just go and do it when I feel it is right to do so”.
  • Call Tracking
    Find usages, find usages, find usages. Formerly, attempting to track call sequences in code could end up with lost context, lots of Find Results windows and frustration. With ReSharper 5, you can inspect an entire call sequence in a single window in a simple and straightforward manner. Stuck in unfamiliar code? ReSharper’s code inspecting tools for the rescue!
  • Value Tracking
    Value Tracking provides you with important information about data flow in your program. At any point in your source code, select a variable, parameter, field or property and ask ReSharper to inspect it. You will then see how its value flows through your program, back to its sources or straight to consumers. Wonder how null could be passed to a specific parameter? Track it!
  • Internationalization
    Software localization and globalization has always been a tough and at times unwanted task for developers. ReSharper 5 greatly simplifies the process of working with resources by providing a full stack of features for ResX files and resource usages in C# and VB.NET code, in ASP.NET and XAML markup. Move string to resource, Find usages of resource and other navigation features, refactoring support, inspections and fixes — all ReSharper goodness for your localization pleasure.
Technologies and Languages
  • Visual Studio 2010
    We will publish more information about Visual Studio 2010 support when VS Beta 2 is released. Currently, ReSharper 5 builds support Visual Studio 2005 and Visual Studio 2008.
  • C# 4 and VB10
    New language versions appear at a great speed nowadays, and ReSharper team works hard to support them right when you need them. ReSharper 5 provides beta support for C# 4 and VB10, as Visual Studio 2010 does itself. Variance, dynamic types, named arguments and optional parameters, embedded COM assemblies — all of these features are supported in the new ReSharper. During VS 2010 Beta 2 phase we’re hoping to learn from your experience using these features and improve their support for Visual Studio 2010 release.
  • ASP.NET
    With this new version, ReSharper support for ASP.NET is improved tenfold. In addition to performance and responsiveness improvements, lots of new features for ASP.NET markup files are introduced to make your life easier. Web-specific navigation, master page support, new inspections and syntax highlighting for web files, File Structure and Go to File Member for in-page navigation and overview, live templates for common markup and more!
  • ASP.NET MVC
    ASP.NET MVC deserved our special attention: special syntax highlighting, inspections, navigation to and from action or controller, and even actions to create new types and methods from usage in pages.
Productivity
  • IntelliSense
    ReSharper continues to bring first-class IntelliSense experience, and the new version gives even more. We have added automatic completion for enum members and boolean values, made automatic triggering smarter, and greatly improved speed. Completion for unresolved symbols in local scope is a new ReSharper IntelliSense feature. Another improvement is completion for all-lower text with CamelHumps  — to make cocopro match CodeCompletionProvider — and that means you don’t need to press Shift too often.
  • Bookmarks
    This is a simple yet powerful feature: drop a numbered marker with a single shortcut, jump back at any time with another keyboard key. Up to 10 numbered bookmarks, unlimited unnumbered bookmarks, full list of bookmarked positions in a single pop-up window — all to help you switch between several code spots instantly.
Inspections
  • Solution-Wide Warnings and Suggestions
    We have received a lot of positive feedback from our users regarding solution-wide error analysis that allows you to immediately see compilation errors in whole solution. In ReSharper 5, we took this technology to a new level by adding warnings and suggestions to the list. Now you can browse code smells that ReSharper finds across your solution and quickly improve quality of your code.
  • Upgrade-to-LINQ Actions
    With C# 3.0 and LINQ, developers are able to write data-intensive code more easily by directly describing their intent to the compiler. However, years of imperative programming left us with tons of foreach-style code waiting to be upgraded. ReSharper 5 detects parts of your code that can be rewritten using the new LINQ syntax and suggests to make the conversion automatically, to make the developer’s intent crystal clear.
  • Use IEnumerable Where Possible
    With the power of LINQ, IEnumerable is more than enough to pass a collection of values. So why restrict yourself with API requiring you to pass old-school arrays, Lists and ArrayLists? ReSharper will scan your code base to detect methods that can safely return and accept IEnumerable instead of a more specific type. Of course, we will also take care of the conversion.
  • New and Improved Code Inspections
    We have collected rich customer feedback and went through a list of common errors that developers make in code. Based on that, we have added a ton of highly intelligent inspections to immediately boost your .NET expertise. For example, if you take your API seriously and want it to be well documented, ReSharper will help you by highlighting errors in XML comments.
Other improvements
  • Native NUnit Support
    ReSharper 5 introduces a completely new approach to running your NUnit tests. Our engine is now based on native NUnit code. What it means to you is 100% compatibility with the latest released version of NUnit and full support of its recent unit testing features.
  • XML Formatting
    XML data is an important part of modern applications and you want it to be in order. The new version of ReSharper is supplied with superb configurable formatter for XML files.
Posted: Oct 12 2009, 08:29 PM by lkempe | with 3 comment(s)
Filed under:
Unit Tests without leaving the keyboard

I like the Roy Osherove blog: Five Whys, Leadership in software teams.

Follow up on those two posts “How to measure programmer productivity using TDD Katas” or “Be Productive and Go Mouseless”. I would like to share a little keyboard shortcut which save me quite some time on my daily developments.

As you might know I am a fan of ReSharper and when I am doing Test Driven Development I hate having to switch from keyboard to mouse to run the test I just wrote. So searching for ReSharper Keyboard command I found Resharper_UnitTest_ContextRun which I assign to the Ctrl+Shift+<.

Now I can run the unit test I just wrote with just a combination of keys which are really near to each other so really easy!

The bonus of this command is that if I have the cursor in one unit test in a TestFixture class then it will run that particular test, but if I have the cursor out of any unit test method it will run all tests of that TextFixture. Very efficient!

Enjoy it!

More Posts