Setting The ClickOnce PublishState In Internationalized Applications

There is quite a bit to know about deploying internationalized applications using ClickOnce. I cover this subject in the Windows Forms Specifics chapter of my book .NET Internationalization and also in my presentation "Deploying Internationalized Applications Using ClickOnce" (slides, MSDN Webcast). One of the problems that arises in this process is how to set the PublishState of localized files that are deployed using ClickOnce. This post explains the utilities that I have written for this purpose. You can download the source code the book (including these utilities) from

Here’s a very quick introduction to the issue that this post is concerned with (the whole subject is much bigger than just what I’m covering here). Say you have a Windows Forms application that has been localized into many different cultures (e.g. French, French (France), French (Canada), Spanish, Spanish (Spain) and Spanish (Mexico)). Now open up the project’s Properties, select the Publish tab, click on the "Application Files..." button and check the "Show all files" checkbox. You will see all of the localized resource files (e.g. fr\WindowsApplication1.resources.dll, fr-FR\WindowsApplication1.resources.dll etc.). By default the Publish Status will be set to "Auto". This means that whether the file is included or not is determined by the Publish Language. In some scenarios (e.g. publishing families of related cultures) you want to take explicit control over this process and manually include or exclude these files regardless of the setting of the Publish Language. This is easy to do with Visual Studio - you just drop down the combo box and set it to Include or Exclude. It is much harder to do with msbuild (where it is arguably more important because you want to automate the build process) and that’s what the utilities in this post are for.

In Visual Studio if you set the French resources to Include you will see the following section added to the .csproj or .vbproj file in one of the ItemsGroup elements:-

PublishFile Include="fr\WindowsApplication1.resources"

This PublishFile will have a PublishState that is set to "Include". There is no way to set this value using msbuild. Until now. Introducing the SetPublishState command line utility and the SetPublishStateTask msbuild task (these are included in the downloadable Visual Studio 2005 source code for the .NET Internationalization book that you can download here).

The SetPublishState command line utility can be called like this:-

SetPublishState WindowsApplication1.csproj fr:Include fr-FR:Include fr-CA:Include All:Exclude

The first parameter is the name of the project file to change. The remaining parameters are a list of cultures and whether to set them to Include or Exclude. Notice the "All" parameter at the end of the list. This optional parameter specifies what to set all of the remaining other cultures to. So in this example the fr, fr-FR and fr-CA cultures are set to Include and the es, es-ES and es-MX cultures are set to Exclude. This would be correct if you wanted to publish the French cultures in one operation. Having performed the publish operation you would then execute the following command:-

SetPublishState WindowsAppl

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Guy Smith-Ferrier
Posted on: Sunday, November 04, 2007 at 6:49 PM
Categories: Internationalization
Actions: E-mail | Kick it! | DZone it! |
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Related posts