News

Laurent Kempé MVP JetBrains Academy Member

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

Links

Tech Head Brothers

Displaying application version on TeamCity home page

I wanted today to display the application version in front of our builds, something I already did on the past but never with the VCS version.

In fact I used the same BUILD_VCS_NUMBER_<simplified VCS root name> that I described here: Build multiple ClickOnce deployment packages using MSBuild and Team City

Go in the General Settings of your build and adapt as following:

4097914182_2e086aabc1_o[1]

When your software is built it will now display the version:

4097158651_22d00c0ac1_o[1]

Posted: Nov 12 2009, 10:00 AM by lkempe | with no comments
Filed under:
Automating Publish of ClickOnce with TeamCity

The other day I published different posts about the way I automated our build process at Innoveo Solutions to generate different ClickOnce setup using TeamCity:

Build multiple ClickOnce deployment packages using MSBuild and Team City
Building ClickOnce with TeamCity
ClickOnce certificate and TeamCity
Build ClickOnce deployment packages using MSBuild and Team City

Yesterday I was asked to solve one minor issue. At ClickOnce publishing time the publish.htm file was not generated so the ClickOnce version number on the web page wasn’t shown. The publish.htm file is a static file on the targeted deploy directory and IIS uses that file. The file contains a hard coded version 2.0.0.x.

So from a user perspective it was difficult to know if there were a new version. So I was asked to show the correct version.

I knew from past research a way to handle this from the following post: How To: Generate publish.htm with MSBuild

But I went to a more pragmatic solution, as I already had the MSBuild Community Tasks.

I made a copy of Publish.htm to Publish.htm.ori on each targeted deploy directory.

Then I modified my MSBuild script to do the following:

  1. Copy Publish.html.ori to Publish.htm
  2. Use FileUpdate of MSBuild Community Tasks to search the 2.0.0.x string and replace it with the version
  1. <!-- Deploy Click Once-->
  2. <Target Name="DeployClickOnce">
  3.   <Message Text="####### Deploy ClickOnce $(Configuration)|$(Platform)  ---------#" />
  4.   <Exec Command="xcopy /E /Y $(ClickOnceSrc)\*.* $(ClickOnceDestination)" />
  5.   <Copy SourceFiles="$(ClickOnceDestination)\Publish.htm.ori" DestinationFiles="$(ClickOnceDestination)\Publish.htm" />
  6.   <FileUpdate
  7.     Files="$(ClickOnceDestination)\Publish.htm"
  8.     Regex="2.0.0.x"
  9.     ReplacementText="$(FullVersion)" />
  10. </Target>

and the FullVersion is defined as this, using TeamCity BUILD_VCS_NUMBER, which is Latest VCS revision:

  1. <Major>2</Major>
  2. <Minor>0</Minor>
  3. <Build>0</Build>
  4. <Revision>$(BUILD_VCS_NUMBER_app_Trunk)</Revision>
  5. <FullVersion>$(Major).$(Minor).$(Build).$(Revision)</FullVersion>  </PropertyGroup>

And now the Publish webpage display the version correctly!

4094558371_70b24140cc_o[1]

Watch Several TeamCity Servers With Windows Tray Notifier

Browsing TeamCity documentation this evening I discovered that it is possible to Watch Several TeamCity Servers With Windows Tray Notifier

TeamCity Tray Notifier is used normally to watch builds and receive notifications from a single TeamCity server.

In situations, when you have more than one TeamCity server, and want to monitor them with Windows Tray Notifier simultaneously, you need to start a separate instance of Tray Notifier for each of the servers from the command line with the /allowMultiple option:

  • navigate to TeamCity Tray notifier installation folder (by default, it's C:\Program Files\JetBrains\TeamCity and run the command:
    JetBrains.TrayNotifier.exe /allowMultiple

    Optionally, for each of the Tray Notifier instances you can specify explicitly the URL of the the server to connect to with the /server option. Otherwise, for each further tray notifier instance you will need to log out and change server's URL via UI.

    JetBrains.TrayNotifier.exe /allowMultiple /server:http://myTeamCityServer

See also details in the issue tracker.

So now I am able to have two TeamCity Tray notifier open:

What I also like is to be able to start programs by typing the Windows key and then some text, here for example “te”

4076003432_6c2b8f449f_o[1]

To achieve this I created three shortcuts with the different servers configuration and then I placed the shortcuts in my folder C:\Users\Laurent\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu in which it is indexed.

Nice!

Posted: Nov 04 2009, 08:49 PM by lkempe | with no comments
Filed under:
Windows Backup, Xbox 360 media extender and 0x80070002 error

Yesterday I bought a new Western Digital external hard drive of 1TB for 109CHF, incredible how cheap it is now.

Then I configured my Windows 7 backup to use this new hard drive, very easy and the backup in less than 2 minutes.

At the end the backup failed because of drive having errors, then after a Error-checking everything was fine.

So I restarted the backup and got again an error:

Backup encountered a problem while backing up file C:\Users\Mcx1-xx-PC\Contacts. Error:(The system cannot find the file specified. (0x80070002))
Backup encountered a problem while backing up file C:\Users\Mcx1-xx-PC\Searches. Error:(The system cannot find the file specified. (0x80070002))
Backup encountered a problem while backing up file C:\Users\Mcx2-xx-PC\Contacts. Error:(The system cannot find the file specified. (0x80070002))
Backup encountered a problem while backing up file C:\Users\Mcx2-xx-PC\Searches. Error:(The system cannot find the file specified. (0x80070002))

Searching on the Internet I found a forum post with the following solution:

This is a known issue with Media center users. For such users, Windows does not create "Contacts" and "Searches" directories which Windows backup expect to be present. As a workaround, please do the following:
1. Launch Change backup settings.
2. Choose the same backup target and proceed to next page.
3. Select "Let me choose".
4. Expand the user Mcx1-NEO node in the treeview. Expand "Additional locations".
5. Exclude the Contacts and Searches directories for the user.
6. Proceed with configuration and save settings.

4071003833_d19380d9ab_o[1]

Restarted backup and now it works!

Build multiple ClickOnce deployment packages using MSBuild and Team City

The other day I posted about Build ClickOnce deployment packages using MSBuild and Team City, and there were something that I didn’t liked in my way of doing it.

I have multiple ClickOnce deployment packages created using TeamCity and MSBuild but each ClickOnce packages have their own Application Revision due to the usage of TeamCity BUILD_NUMBER server build property.

So I changed to use TeamCity BUILD_VCS_NUMBER_<simplified VCS root name>

  1. <!-- ClickOnce getting build number from Team City -->
  2. <ApplicationRevision>$(BUILD_VCS_NUMBER_MyApplication_Trunk)</ApplicationRevision>

And now all my ClickOnce packages have the same Application Revision which is better !

Building ClickOnce with TeamCity

Migrating our TeamCity server today I got the following error on the new server:

error MSB3147: Could not find required file 'setup.bin' in …

I for sure fixed that on the older server, and the fix was to have the SDK on the build server. The issue is that I don’t want to install Visual Studio to do that, so here is how I achieved it

  1. Copy my whole c:\Program Files\Microsoft SDKs\Windows\v6.0a folder to the server
  2. Created a registry key
    Key: HKEY_LOCAL_MACHINE\Software\Microsoft\GenericBootstrapper\3.5\
    Value: Path
    Type: REG_SZ
    Data: C:\Program Files\Microsoft SDKs\Windows\v6.0a\Bootstrapper\

Then the error was gone and I had my build server ready again to build ClickOnce setup.

TeamCity migration tip

Today I am migrating a TeamCity installation from an old server to a new server and discovered that it is really easy to do that!

First I fully re-installed TeamCity using the Windows Setup that JetBrains delivered on the new server.

Then I stopped the old and new instances and transferred the folder .BuildServer from the old server to the new server.

Restarted the new instance and got all my settings from the old instance on the new instance (projects, users…)

This saved my day! and lots of work! Thank you JetBrains for this great tool.

Update

If you set on the original server the Server URL, don’t forget to update it to the new Server URL. This can be done through the Administration > Server Configuration page.

ClickOnce certificate and TeamCity

To be able to run a build on TeamCity of a Visual Studio solution containing a ClickOnce manifest which needs to be signed, you will need to add the certificate to the Windows account on which TeamCity services runs.

TeamCity run under Local System account per default.

4068846824_d9a73b13b8_o[1]

So you need to add the certificate to this account! But how do you do that?

You will need a tool from SysInternals called PsExec, then using PsExec:

> Psexec.exe -i -s cmd.exe

you will have ran a command prompt on your system in the Local System Account (LSA).

Using that new command prompt, cd to the folder containing your certificate and start it

> my_TemporaryKey.pfx

Then you will face the Certificate Import Wizard in which you click Next > Next > Type the password > Next.

Your certificate is installed now for Local System Account (LSA), and your build should work now.

Enjoy!

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]

More Posts Next page »