Create a clickonce webdeploy package
Asked Answered
C

1

7

Is it possible to build a web deploy package containing a clickonce application that can be deployed to a web server using the standard webdeploy tool?

Here would be the ideal process:

  1. MSBuild "YourFullyQualifiedProjectName.csproj/vbproj" /T:Package
  2. obj\Debug\Package\YourFullyQualifiedProjectName.deploy.cmd /Y

The reasoning behind this would be so we can build the whole solution including web packages, run all tests, then deploy only after tests pass.

I've currently looked at doing a file-based deploy to a temp folder, copy that into a web project, then package the web project. Is there a neater solution?

Chura answered 15/2, 2012 at 12:1 Comment(2)
Do you want to create a Web Deploy package of just the ClickOnce content or do you want to incorporate it into a Web Deploy package which gets generated for a web project (i.e. a different project in the solution which is a web project)?Wyon
Was just the ClickOnce content I need to deploy.Chura
W
9

I have created a blog for this at http://sedodream.com/2012/02/18/HowToCreateAWebDeployPackageWhenPublishingAClickOnceProject.aspx which has more details, but the relevant pieces are below

If you have a client project which you want to create a ClickOnce package out of then you can try the following.

Edit the project file for your client project and add the following at the bottom (right above the </Project> tag).

  <PropertyGroup>
    <!--Unless specified otherwise, the tools will go to HKLM\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\1 to get the installpath for msdeploy.exe.-->
    <MSDeployPath Condition="'$(MSDeployPath)'==''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\3@InstallPath)</MSDeployPath>
    <MSDeployPath Condition="'$(MSDeployPath)'==''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\2@InstallPath)</MSDeployPath>
    <MSDeployPath Condition="'$(MSDeployPath)'==''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\1@InstallPath)</MSDeployPath>
    <MSDeployExe Condition=" '$(MSDeployExe)'=='' ">$(MSDeployPath)msdeploy.exe</MSDeployExe>
  </PropertyGroup>

  <Target Name="CreateWebDeployPackage" AfterTargets="Publish" DependsOnTargets="Publish">
    <!--
    %msdeploy% 
      -verb:sync 
      -source:contentPath="C:\Temp\_NET\WebPackageWithClickOnce\WebPackageWithClickOnce\bin\Debug\app.publish" 
      -dest:package="C:\Temp\_NET\WebPackageWithClickOnce\WebPackageWithClickOnce\bin\Debug\co-pkg.zip"
      -->
    <PropertyGroup>
      <Cmd>"$(MSDeployExe)" -verb:sync -source:contentPath="$(MSBuildProjectDirectory)\$(PublishDir)" -dest:package="$(OutDir)cotest.zip"</Cmd>
    </PropertyGroup>

    <Message Text="Creating web deploy package with command: $(Cmd)" />
    <Exec Command="$(Cmd)" />
  </Target>

In the PropertyGroup I am:

  • declaring the name of the web deploy package
  • trying to see where MSDeploy is installed

After that the CreateWebDeployPackage is defined which will get executed after the PublishOnly target (because of AfterTargets="PublishOnly"). That target will make a call to msdeploy.exe to create the package in the output directory. You should be able to take that package and publish it as you would any other package.

Can you try it and let me know if it works for you?

Wyon answered 17/2, 2012 at 7:10 Comment(5)
That's fantastic, thanks for the very complete solution, much appreciated!Chura
+1 I believe that if asked, Sayed is able to make espresso coffee with msbuildGrandam
@Grandam I wish I could make espresso using MSBuild. Would save me a ton of $$$ :)Wyon
I know this answer has some months seen already, but maybe you can answer this. Is there a way to achieve this without altering the project file? I know I can provide properties as parameters to msbuild and I really would like to get this going without having to edit project files for just adding one target.Baur
After I publish the task is not even invoked.Interrelate

© 2022 - 2024 — McMap. All rights reserved.