If you are using an automated build tool, such as CruiseControl.NET, and signing applications for use via the Internet, the Mage.exe tool will give you much more flexibility when you create a ClickOnce deployment. Here is a good ClickOnce walkthrough for both methods.
Here is a batch file you can use to create the deployment. One of these days I will get around to learning PowerShell :)
REM ****************************************************************
REM * File: PublishClickOnceApp.bat *
REM * Author: Dennis Somerville *
REM * Description: This batch file will publish an application as *
REM * a Microsoft ClickOnce deployment. This uses *
REM * Mage.exe command-line utility to create the *
REM * application and deployment manifests. *
REM * Pre-req: .NET Framework 3.5, Windows SDK's *
REM ****************************************************************
@echo off
REM Change these settings, or make them command-line parameters for the batch file.
set version=1
set major=0
set minor=0
set revision=0
set applicationFileDir=Application Files\DelaySignTest_%version%_%major%_%minor%_%revision%
set appName=MyApp
set exeName=%appName%.exe
set manifestName=%exeName%.manifest
set applicationFileName=%appName%.application
set exePath=%applicationFileDir%\%exeName%
set certificate=mycert.pfx
set certificatePassword=mypassword
set publishDir=C:\inetpub\wwwroot\MyApp
set publishBase=http://localhost/MyApp/
set sourceDir=..\%appName%\bin\Release
set publisherName=My Company Name
set mageExe="C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mage.exe"
set msbuildExe="C:\windows\microsoft.net\framework\v3.5\msbuild.exe"
@echo on
REM Cleanup
rd /s /q ".\Application Files\"
del /s /q %publishDir%\*
REM Build
%msbuildExe% /target:Clean;Rebuild /property:configuration=RELEASE;PublisherName="The Sherwin-Williams Company";ProductName="DelaySignTest" "..\DelaySignTest.sln"
REM Copy source files to mage directory
xcopy /y %sourceDir%\*.exe "%applicationFileDir%\"
xcopy /y %sourceDir%\*.dll "%applicationFileDir%\"
del /q "%applicationFileDir%\*.vshost.*"
REM Signing executable
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\signtool" sign /f %certificate% /p %certificatePassword% "%exePath%"
REM Creating Deployment
%mageExe% -New Application -ToFile "%applicationFileDir%\%manifestName%" -FromDirectory "%applicationFileDir%" -Name "%appName%" -Version %version%.%major%.%minor%.%revision%
%mageExe% -Sign "%applicationFileDir%\%manifestName%" -CertFile %certificate% -Password %certificatePassword%
%mageExe% -New Deployment -Install false -ToFile "%applicationFileName%" -AppManifest "%applicationFileDir%\%manifestName%" -Name "%appName%" -ProviderURL "%publishBase%%applicationFileName%" -IncludeProviderURL true -Version %version%.%major%.%minor%.%revision%
%mageExe% -Sign %applicationFileName% -CertFile %certificate% -Password %certificatePassword%
REM Publishing
xcopy /y .\%applicationFileName% %publishDir%
xcopy /y /s /i ".\Application Files" "%publishDir%\Application Files"


0 comments:
Post a Comment