Summary:. Discusses how to build a ClickOnce application from the command-line outside of Visual Studio .NET using MSBuild Also provides an overview of the manifest generation tasks and shows how to use them directly This document assumes some familiarity with MSBuild and the structure. Of XML Manifest Files.
Note: This document was developed prior to the product's release to manufacturing, and as such, you may find inconsistencies with the details included here and those found in the shipping product The information is based on the product at the time this document was created and. should be used for planning purposes only. Information is subject to change at any time without prior notice. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any Written license agreement from Microsoft, The Furnishing of this Document Does Not Give You Any License To The Patents, Trademarks, Copyrights, or Other Intellectual property.
BUILDING from The Command-Line Is Important for Some Customers To Reproduce The Build in An Automated Way, In A Build Lab for instance.
SHOULD BE FAMILIAR with MSBUILD AND CLICKONCE PUBLISHING.
Introduction
A major new capability of Whidbey is the ability to build your projects outside of the Visual Studio 2005 IDE. In fact, all you need to build your projects is the .NET Framework, Visual Studio 2005 is not required strictly for building projects! This is a key capability for customers who need to be able to reproduce the build using an automated process. for instance, in a central build lab or using advanced scripting techniques beyond the scope of the project itself.This document discusses the following topics. First, the basics of building from the command line a ClickOnce deployment using an existing project created with Visual Studio 2005. Next for those who wish to know what's going on under the hood, an overview of MSBuild will be given focusing on how generating ClickOnce manifests are integrated into This System. Finally, The Components That Perform The Manifest Generation Will Be Described in Detail, Along With A Few Additional Samples Demonstrating How To Control THEM DIRECTLY .
The next section discusses how manifests are actually generation within the MSBuild system. This is not required reading unless you have a need to interact with the MSBuild tasks for manifest generation directly, or if you are just interested in the lower level details.
Basics of Command Line Build
BEFORE We can Demonstrate Building from the command-line, We need to create a project. Follow these Steps to create a new project.
Start Visual Studio 2005. Choose File, New Project to open the New Project dialog. Create a new Windows Application (Visual Basic or Visual C #) and name it "CmdLineDemo". Choose the Build menu and select the Publish command. From the wizard, Click ON Finish. Save The Project, And Choose a Folder If Necessary.
Now That We Have a Project Time, Let's Exit Visual Studio .NET and See IF We Can Reproduce The Build Outside of The Ide.
Exit Visual Studio 2005. Open a Visual Studio Command Prompt, click on Start, All Programs, Microsoft Visual Studio 2005 Beta, Visual Studio Tools, Visual Studio Command Prompt. This should open a command prompt in the root folder of the current user. Change THE CURRENT DIRECTORY TO The Location of The Project You Just Built Above.for Example, Type "Chdir my documents / visual studio / projects / cmdlinedemo". Type "Msbuild / Target: Publish".
This Will Produce A Full Clickonce Application Deployment In A Sub - Folder Named "Publish".
CmdLineDemo.application is the deployment manifest. The CmdLineDemo_1.0.0.0 folder contains files CmdLineDemo.exe and CmdLineDemo.exe.manifest, which is the ClickOnce application manifest. Setup.exe is the bootstrapper, which by default is configured to install the. NET Framework. The DotNetfx Folder Contains The Redistributables for the .NET Framework. This is everything you need to deploy your application over the Web or via UNC OR CD / DVD!
So how is this "publish" folder produced When you invoke?. "Msbuild / target: publish" at the command line, it tells the MSBuild system to build the project and create a ClickOnce deployment in the "publish" folder This is equivalent to selecting the publish command in the IDE in step # 4 above Breaking this down, the "msbuild" part runs a program named "msbuild.exe" which is on the path in the Visual Studio command prompt environment The "/ target:.. publish "part tells MSBuild to invoke the" publish "target, which we'll discuss in more detail shortly. incidentally, the other interesting target is the" build "target, which simply builds your application. If you just wanted to build your project you . can achieve that by typing "msbuild" The "build" target is the default target for this project, so you do not explicitly need to specify it So typing "msbuild" or. "msbuild / target: build" is equivalent to selecting THE BUILD Command in the ide.in addition to invoking the "publish" target, there are several settings in your project that control how the ClickOnce deployment is generated within the "publish" target. It may be important to understand these details in order to properly manage your command-line builds. The next few sections discuss the various project settings that PRIMARILY INFLUENCE PUBLISHING AND CLICKONCE MANIFEST generation.
Other than the application itself, there are three factors which directly influence the ClickOnce application and the generated manifests. These factors are publishing properties, publishing item metadata, and the base app.manifest file.
Publishing Properties
When You Performed Step # 4 Above The Following Properties Were Insert Int Into Your Project File.
CmdlineDemo.vbproj / cmdlinedemo.csproj
These properties are controlled in the IDE from the Publish, Security, and Signing property pages of the application designer. Below is a description of the publishing properties, along with an indication of how each is set in the various property pages of the application designer.
....................................
The Following Properties Are Set on The Publish Page.
PublishUrl is the location where the application will be published to in the IDE. It is inserted into the ClickOnce application manifest if neither the InstallUrl or UpdateUrl are specified. This is set by the "Publishing location" textbox on the Publish page.
ApplicationVersion specifies the version of the ClickOnce application. This is a four digit version number. If the last digit is a "*", then the ApplicationRevision is substituted. This value is set by the "Major", "Minor", and "Build "TextBoxes on the publication. This is an integer incrtain. This value is set by the" revision "textbox on the public page.
Install determines WHETHER THE Application IS An Installed Application, or a run-from-web application. This is set by the "online / offline" Radio Buttons on The Publish Page.
InstallUrl (not shown) is the location where users will install the application from. If specified, this value is burned into the setup.exe bootstrapper if the IsWebBootstrapper property is enabled. It is also inserted into the application manifest if the UpdateUrl is not specified .
The Following Properties Are Set on The Application Updates Dialog
UpdateEnabled Indicates WHether The Application Should Check for Updates. This is set by the "check for updates" Checkbox on the update dialog, access from the public point page.
Updatemode Specifies Either Foreground Updates or Background Updates.
UpdateInterval Specifies How Frequently The Application Should Check for Updates.
UpdateIntervalUnits Specifier The WHETHER THE UpdateInterval Value IS in Units of Hours, Days, or Weeks.
UpdateUrl (not shown) is the location from which the application will receive updates. If specified, this value is inserted into the application manifest. This value is set by the "Update location" textbox on Update dialog, accessed from the Publish page.
The Following Properties Are Set on The Prerequisites Dialog, Accessed from The Publish Page.Bootstrapperenabled Dermines WHether Not To Genereate The Setup.exe Bootstrapper.
Iswebbootstrapper determines WHETHER THETUP.EXE Bootstrapper Works over The Web OR in Disk based Mode.
Why are there three URL's? If you are publishing to a web URL, only PublishURL needs to be specified. You only need to specify the other URL's if they are different from the PublishURL. In the IDE, you may want to publish to a different path from which your end-users to install. For example, you could set the publishURL to an FTP path and set the installURL to a web URL. in this case, the publishURL is only used in the IDE to transfer the files, but not Used in the command-line builds. Finally, UpdateURL Can Be Used If You Want To Publish A Clickonce Application That Updates Itself from a Separate Location from Which it is installed.
Incidentally, you can override any of these properties at the command line without altering the project file itself. For example, the following will build the ClickOnce application deployment without the bootstrapper.
Msbuild / Target: Publish / Property: Bootstrapperenabled = false
Publishing Item Metadata
In Visual Studio 2005 the Application Files dialog, accessed from the Publish page, allows you to customize how each file is published. For example, you can specify that certain files should not be published with the application. How this actually works
For example, you can specify that an .txt file is a data file, or What if you want to set certain files into a group, or set an assembly as a prerequisite? This is controlled with publishing attributes, which appear on various items in Your Project.
These attributes are set in Visual Studio 2005 on the File dialog, accessed from the Publish page. The Type setting allows you to control whether the file is included or excluded from the deployment. If excluded, a file will not be present in the publish folder And Will NOT APEAR IN THE Generated Manifest. An additional setting for Type Dependends on WHETHER THE ITEM IS A File (IE .xml, .mdf) or an assembly (ie .dll, .exe). For files there is an addressal setting to flag a file as a data file. Flagging a file as a data file tells ClickOnce to migrate that file between multiple versions of your application. For assemblies there is an additional setting that to flag an assembly as a prerequisite. A prerequisite required by the application , but not deployed with it. The assembly will appear in the manifest and ClickOnce will insure it is installed in the Global Assembly Cache before allowing the application to be installed or run.app.manifest
As you can see, any project designed in Visual Studio 2005 can be built and published at the command line using MSBuild. Even sophisticated multi-project solutions can be built in this manner. The only feature not supported at the command line is the ability to Easily Transfer Your Application To A Web Server OR FTP Server Using FrontPage Server ExtensNesions. However, you can commerce for this sale bath files.
This is everything you need to know to get started building ClickOnce applications created in Visual Studio 2005 from the command-line. The next section discusses how manifests are actually generation within the MSBuild system. This is not required reading unless you have a need to interact WITH The Msbuild Tasks for Manifest Generation Directly, or if You Are Just Interested in The Lower Level Details.how IT Works (Advanced)
How does it work? ... Diagram Showing Publishing Properties, Targets, and Xmake Tasks
Publish Target Depends on Build Target
Important for Customers That Build Solutions That Want To Control The Tasks Directly, Not Leverage A Visual Studio Project.
Overview of msbuild
What is msbuild?
XML Based Build Engine
How does it relate to clickonce Publishing?
Enables building projects outside the IDE, Even WITHOUT VISUAL Studio .NET Installed!
All Project Build Functionality Is Based ON Msbuild.
Total Parity Between Ide and Command-Line Builds.
No venus
Show how to override property from command-line, i.e. msbuild / target: Publish / Property: PublishURL = foo
GenerateApplicationManifest Task
The GenerateApplicationManifest task generates a ClickOnce application manifest. A ClickOnce application manifest is an XML document that describes an application by providing a specification of its identity, all of its required dependencies and files, and the level of trust the application requires to run. All files are hashed and the manifest is signed in order to guarantee application integrity. This section includes a sample application manifest and follows with a description of task inputs that control how the manifest is generated.
Sample Application Manifest
This Is A Sample Clickonce Application Manifest Named "Sample.exe.manifest" That Illustrate The Characteristic Output of The GenerateApplicationManifest Task. XML Version = "1.0" Encoding = "UTF-8"?>
XMLns = "URN: Schemas-Microsoft-COM: ASM.V2" XMLns: asmv1 = "URN: Schemas-Microsoft-COM: ASM.V1" XMLns: asmv2 = "URN: Schemas-Microsoft-COM: ASM.V2" XMLns: dsig = "http://www.w3.org/2000/09/xmldsig#" ManifestVersion = "1.0"> (1) Name = "sample.exe" (2) Version = "1.0.0.0" (3) PublickeyToken = "3CB8ABA78866DBBF" (4) Language = "neutral" (5) Processrarchitecture = "msil" TYPE = "Win32" /> (6) (7) this is a name. description> (7) ApplicationRequestMinimum> security> trustinfo> (8) Name = "Sample" Version = "1.0.0.0" Language = "neutral" Processrarchitecture = "msil" /> EntryPoint> (9) Name = "Sample" Version = "1.0.0.0" Language = "neutral" Processrarchitecture = "msil" /> dependentassembly> dependency> (10) (11) CodeBase = "foo.dll" SIZE = "16309" (12) Group = "mydata"> Name = "foo" Version = "1.0.0.0" Language = "neutral" Processrarchitecture = "msil" /> dependentassembly> dependency> (13) Name = "bar" Version = "1.0.0.0" PublickeyToken = "3CB8ABA78866DBBF" Language = "neutral" Processrarchitecture = "msil" /> dependentassembly> dependency> Name = "Microsoft-Windows-CLRCORECOMP" (14) Version = "2.0.3600.0" /> dependentassembly> dependency> (15) file> (16) file> (17) Name = "foo.mdf" Size = "148376 (18) group = "mydata" (19) Optional = "true" (20) WriteableType = "ApplicationData"> file> (21) asmv1: askEMBLY> Task INPUTS The GenerateAplicationManifest task generates an application manifest according to the set of task inputs as described below. Note that some descriptions have numeric references to the sample above in order to more clearly illustrate the generated output.AssemblyName specifies the name attribute of the assembly identity of the manifest. If not specified, then the value is obtained from the base manifest specified by the InputManifest input, or inferred from the value specified in the OutputManifest. This string is inserted into the name (1) attribute of the assemblyIdentity element. AssemblyVersion specifies the version attribute for the assembly identity of the manifest. If not specified then the value is obtained from the base manifest specified by the InputManifest input or from the assembly specified in the EntryPoint input. This string is inserted into the version (2) Attribute of the assemblyidentity element. CertificateFile specifies a key file for X509 certificate signing of the manifest. The item specification must be a relative or absolute path to a certificate (.cer) file. This input item causes the Signature (18) element to be generated. It also determines the PublickeyToken (3) Attribute for the assembly identity of the manifest. Certificateword To Use When Certificate Signing. It is propecified. Dependencies specifies one or more application dependencies that are part of the application. These are additional .NET assemblies required by the main entry point assembly to be deployed along with the application. The item specification must be a relative or absolute path to a .NET assembly (.dll or .exe) File. Each INPUT ITEM WILL Generate A Separate Dependency Element (9, 10) in the manifest. item metadata can be used to specify optional (10) And group (12) Attributes, or To Specify A Codebase (11) Attribute Other Than The Default Value Inferred from The Item Specification.description Specifies A Description for the Manifest. This String Appers in The Description Element (6) of the manifest. EntryPoint specifies a single item that determines the entry point of the application. This is the main program launched when the ClickOnce application is invoked from the deployment manifest or launched from the start menu. The item specification must be a relative or absolute path to a. NET assembly executable (.exe) file. Item metadata can be used to specify optional (10) and group (12) attributes, or to specify a codebase (11) attribute other than the default value inferred from the item specification. FallbackCulture Specifies Files specifies one or more application files that are part of the application. These are additional loose files such as images, config files, or local databases to be deployed along with the application. The item specification must be a relative or absolute path to a file . Each input item will generate a separate file element (15, 16, 17) in the manifest. Use item metadata to specify optional (18), group (19), and writeableType (20) attributes, or to specify a name attribute other than the default value inferred from the item specification.FXVersion specifies the version of the .NET Framework required by this application. This value determines the version attribute on the generated "Microsoft-Windows-CLRCoreComp" platform dependency. IConfile Specifies InputManifest specifies a base manifest to the manifest generation process. The item specification must be a relative or absolute path to a manifest file. The only requirement is that the root element must be the assembly element in the asmv1 namespace. No additional attributes or sub- elements are required, so this can be thought of as a partial manifest template. In a Visual Studio .NET project, this is an optional hidden file called "app.manifest" which is inserted into a project whenever custom permissions are configured on the Security page. It is primarily used to specify the trustInfo element to define custom permission sets. However, additional custom attributes or sub-elements on the root assembly element can be defined. Custom attributes or sub-elements on file and dependency elements is not allowed, And will be dropped. IsolatedComReferences specifies one or more COM components to be isolated. The item specification must be a relative or absolute path to a type-library file. This provides the ability to deploy COM components "registration free". In a Visual Studio .NET project, any project references of type "ActiveX" with Isolated property set to True will be routed into this input.KeyFile specifies a key file for strong-name signing of the manifest. The item specification must be a relative or absolute path to a key file, specifically either a strong-name key file (.snk) or an encrypted strong-name key file (.pfx). This input item causes the Signature (18) element to be generated. It also determines the publicKeyToken (3) attribute for the assembly Identity of the manifest. NativeReferences specifies one or more native dependencies required by the application. These are additional Win32 assemblies required by the main entry point assembly to be deployed along with the application. The item specification must be a relative or absolute path to a native assembly (.dll or .manifest) file. Each input item will generate a separate dependency element in the manifest. However, these dependency elements are distinguished from other dependency elements in that they are generated in the asmv1 namespace, allowing the runtime to resolve native bindings such as "registration Free "Com Components. Item Metadata Can Be Used to Specify Optional (10) And Group (12) Attributes, Or To Specify A Codebase (11) Attribute Other Than The Default Value Inferred from The Item Specification. OSVersion specifies the minimum Windows platform version. For example, "5.1.2600.0" specifies that the application requires Windows XP, which is emitted by default if you are using "registration free" COM.OutputManifest determines the name of the output manifest file. The item specification must be a relative or absolute file path. If not specified, then the path is inferred either from the identity defined in the base manifest specified by the InputManifest input, or from the filename specified in the EntryPoint input. Platform Specifier The Processor Architecture of the Application. Valid Values Are Prerequisites specifies one or more application dependencies required by the application. These are additional assemblies required by the main entry point assembly, but are not deployed with the application. Instead they are assumed to have been pre-deployed via a separate deployment mechanism such as MSI or SMS. However, they are specified here so that ClickOnce can verify their existance before application startup. The item specification must be either a relative or absolute path to a .NET assembly (.dll or .exe) file, or am assembly strong- Name. EACH INPUT ITEM WILL Generate A Separate Dependency Element (13) in The Manifest, Flagged with a Prerequisite Attribute. Satellites specifies one or more satellite assemblies required by the application for the corresponding TargetCulture. These deployed along with the application. The item specification must be a relative or absolute path to a .NET satellite assembly (.dll) file. Each input item will generate A Separate, Optional DepENDENCY Element in the manifest. TargetCulture Specifier The Culture of the Application. If NOT Specified, Culture Neutral is The Default. TrustInfoFile specifies one or more trust licenses to insert into the manifest. The item specification must be a relative or absolute path to a trust license (.tlic) file. Trust licenses are created in a tool called "MAGE" and are primarily used in a Corporate Environment To ALLOW Applications to Be Deployed over a managed network.generatedEPloymentManifest Sample.Application XML Version = "1.0" encoding = "UTF-8"?> XMLns = "URN: Schemas-Microsoft-COM: ASM.V2" XMLns: asmv1 = "URN: Schemas-Microsoft-COM: ASM.V1" XMLns: asmv2 = "URN: Schemas-Microsoft-COM: ASM.V2" XMLns: dsig = "http://www.w3.org/2000/09/xmldsig#" ManifestVersion = "1.0"> (1) Name = "Sample.Application" (2) Version = "1.0.0.0" (3) PublickeyToken = "3CB8ABA78866DBBF" (4) Language = "neutral" (5) Processrarchitecture = "msil" /> (6) ASMV2: Publisher = "Microsoft" (7) ASMV2: Product = "Sample"> (8) this is a name asmv1: description> update> subscription> deployment> Codebase = "Sample_1.0.0.0 / Sample.exe.manifest" SIZE = "3422"> Name = "Sample.exe" Version = "1.0.0.0" PublickeyToken = "3CB8ABA78866DBBF" Language = "neutral" Processrarchitecture = "msil" /> dependentassembly> dependency> asmv1: askEMBLY>