Search code examples
c#.netmsbuildpackagepublish

How to create simple file based distributions for Windows Services and Windows Applications via MSBuild


Firstly, thanks for taking the time to read and possibly comment on this question.

Summary

How can I use MSBuild to automatically package MS Visual Studio Windows Services and Windows Applications into simple (a directory of files including the dlls, exes, configs etc) which I can release to our Dev-Ops dept. I do not want the distribution in MSI installer or setup.exe or some web deployment format which appear to be the default in MS Visual Studio's publish.

My Environment

  • Windows XP SP3 (32-bit), Window Server 2008 R2 (64-bit)
  • .NET 4.0 (32-bit)
  • MS Visual Studio 2010 (32-bit)
  • NAnt 0.91 (32-bit)

My Scenario

Currently, we have about 5 types of MS Visual Studio project and for the first 3 types (Web Services, Web Applications, Web Sites), we can use MSBuild to package the source into a simple directory of files (distribution) based on the contents of the csproj file using:

msbuild my.component.csproj /p:Configuration=Release /t:Package /p:_PackageTempDir="C:\temp\some\dir"

For the latter 2 types (Windows Services, Windows Applications), we cannot use MSBuild as above. From investigation via the Publish command in Visual Studio, it appears that I can create setup.exe installers for both Windows Services and Windows Applications but this is not what I want - I just want to be able to create a simple directory of files (distribution) as I have been doing for the other project types. I accept that this may not be possible but I would just like to know for sure.

Conclusions

Thus far, for both Windows Services and Windows Applications I have come to the following conclusions, the former two, not ideal:

  • Use MSBuild to compile the code and NAnt to create the simple directory of files (distribution).
  • Use MSBuild to compile the code and create a post build event to create the distribution.
  • Your suggestion here (much appreciated).

Solution

  • Based on my research online (MSDN), at StackOverflow and limited local experimentation, it appears that both Windows Services and Windows Applcations cannot be quickly or easily built in a way which is similar to the distribution output of MSBuild's package command, that is, into a local file-based distribution.

    For Windows Applications, as Splattered Bits suggested, the contents of the release bin directory can be used as the simple file-based distribution after the project has been compiled.

    For Windows Services, it is be possible to do what we did for Windows Applications above and use the output from the release bin directory.

    In both cases, a change to the CSPROJ file may be required to suppress the creation of PDB files or futher configuration the compilation output.