Installutil.exe (инструмент для установки) Installutil.exe (Installer Tool)
Программа для установки является программой командной строки, с помощью которой можно устанавливать и удалять ресурсы сервера путем выполнения компонентов установщика в соответствующих сборках. The Installer tool is a command-line utility that allows you to install and uninstall server resources by executing the installer components in specified assemblies. Эта программа работает совместно с классами в пространстве имен System.Configuration.Install. This tool works in conjunction with classes in the System.Configuration.Install namespace.
Эта программа автоматически устанавливается вместе с Visual Studio. This tool is automatically installed with Visual Studio. Для запуска этого средства используйте Командную строку разработчика или PowerShell для разработчиков в Visual Studio. To run the tool, use Visual Studio Developer Command Prompt or Visual Studio Developer PowerShell.
В командной строке введите следующее. At the command prompt, type the following:
Синтаксис Syntax
Параметры Parameters
Аргумент Argument | Описание Description |
---|---|
assembly | Имя файла сборки, в которой должны выполняться компоненты установщика. The file name of the assembly in which to execute the installer components. Пропустите этот параметр, если указывается строгое имя сборки с помощью параметра /AssemblyName . Omit this parameter if you want to specify the assembly’s strong name by using the /AssemblyName option. |
Параметры Options
Параметр Option | Описание Description |
---|---|
/h[elp] |
/?
/? сборка /? assembly
Version = основная.дополнительная.сборка.редакция, ,Version=major.minor.build.revision
Culture = языковой стандарт, ,Culture=locale
PublicKeyToken = publicKeyToken» ,PublicKeyToken=publicKeyToken«
Например, «myAssembly, Culture=neutral, PublicKeyToken=0038abc9deabfle5, Version=4.0.0.0» — это полное имя сборки. For example, «myAssembly, Culture=neutral, PublicKeyToken=0038abc9deabfle5, Version=4.0.0.0» is a fully qualified assembly name.
Дополнительные параметры установщика Additional Installer Options
Отдельные установщики, используемые в сборке, кроме перечисленных в разделе Параметры, могут распознавать и другие параметры. Individual installers used within an assembly may recognize options in addition to those listed in the Options section. Чтобы узнать об этих параметрах, запустите программу InstallUtil.exe с путями к сборкам в командной строке, а также с параметром /? или /help . To learn about these options, run InstallUtil.exe with the paths of the assemblies on the command line along with the /? or /help option. Чтобы задать эти параметры, необходимо включить их в командную строку вместе с параметрами, распознаваемыми программой InstallUtil.exe. To specify these options, you include them on the command line along with the options recognized by InstallUtil.exe.
Текст справки о параметрах, поддерживаемых отдельными компонентами установщика, возвращается свойством Installer.HelpText. Help text on the options supported by individual installer components is returned by the Installer.HelpText property. Отдельные параметры, которые были введены в командной строке, доступны программно из свойства Installer.Context. The individual options that have been entered on the command line are accessible programmatically from the Installer.Context property.
Все параметры командной строки записываются в файл журнала установки. All options and command-line parameters are written to the installation log file. Однако если используется параметр /Password , распознаваемый некоторыми компонентами установщика, сведения о пароле будут заменены восемью звездочками (*) и не будут отображаться в файле журнала. However, if you use the /Password parameter, which is recognized by some installer components, the password information will be replaced by eight asterisks (*) and will not appear in the log file.
В некоторых случаях передаваемые в установщик параметры могут содержать конфиденциальные или личные сведения, которые по умолчанию записываются в обычный текстовый файл журнала. In some cases, parameters passed to the installer may include sensitive or personally identifiable information, which, by default, is written to a plain text log file. Для предотвращения этого поведения можно запретить ведение журнала, указав в командной строке /LogFile= (без аргумента имя_файла) после программы Installutil.exe. To prevent this behavior, you can suppress the log file by specifying /LogFile= (with no filename argument) after Installutil.exe on the command line.
Примечания Remarks
Приложения .NET Framework состоят из традиционных файлов программ и связанных с ними ресурсов, таких как очереди сообщений, журналы событий и счетчики производительности, которые создаются при развертывании приложения. .NET Framework applications consist of traditional program files and associated resources, such as message queues, event logs, and performance counters that must be created when the application is deployed. Компоненты установщика сборки могут использоваться для создания таких ресурсов при установке приложения и для их удаления при удалении приложения. You can use an assembly’s installer components to create these resources when your application is installed and to remove them when your application is uninstalled. Программа Installutil.exe обнаруживает и выполняет эти компоненты установщика. Installutil.exe detects and executes these installer components.
В командной строке можно указать сразу несколько сборок. You can specify multiple assemblies on the same command line. Параметры должны указываться перед именами сборок, к установке которых они относятся. Any option that occurs before an assembly name applies to that assembly’s installation. За исключением /u и /AssemblyName , параметры являются накопительными, но переопределяемыми. Except for /u and /AssemblyName , options are cumulative but overridable. То есть параметры, указанные для одной сборки, применяются и ко всем последующим сборкам. Исключением являются параметры, с которыми указывается новое значение. That is, options specified for one assembly apply to all subsequent assemblies unless the option is specified with a new value.
При запуске программы Installutil.exe для сборки без указания параметров она помещает в каталог сборки следующие три файла. If you run Installutil.exe against an assembly without specifying any options, it places the following three files into the assembly’s directory:
InstallUtil.InstallLog — содержит общее описание хода выполнения установки. InstallUtil.InstallLog — Contains a general description of the installation progress.
имя_сборки.InstallLog — содержит сведения, относящиеся к этапу фиксации процесса установки. assemblyname.InstallLog — Contains information specific to the commit phase of the installation process. Дополнительные сведения об этапе фиксации см. в описании метода Commit. For more information about the commit phase, see the Commit method.
имя_сборки.InstallState — содержит данные, используемые для удаления сборки. assemblyname.InstallState — Contains data used to uninstall the assembly.
Программа Installutil.exe использует отражение для проверки указанных сборок и поиска всех типов Installer, у которых значение атрибута System.ComponentModel.RunInstallerAttribute имеет значение true . Installutil.exe uses reflection to inspect the specified assemblies and to find all Installer types that have the System.ComponentModel.RunInstallerAttribute attribute set to true . Программа, выполняющая метод Installer.Install или Installer.Uninstall для каждого экземпляра типа Installer. The tool then executes either the Installer.Install or the Installer.Uninstall method on each instance of the Installer type. Программа Installutil.exe выполняет установку как транзакцию, то есть если какую-либо сборку не удалось установить, отменяется установка всех остальных сборок. Installutil.exe performs installation in a transactional manner; that is, if one of the assemblies fails to install, it rolls back the installations of all other assemblies. Удаление не считается транзакцией. Uninstall is not transactional.
Программа Installutil.exe не может устанавливать или удалять сборки с отложенной подписью, но может устанавливать и удалять сборки со строгими именами. Installutil.exe cannot install or uninstall delay-signed assemblies, but it can install or uninstall strong-named assemblies.
Начиная с .NET Framework версии 2.0, 32-разрядная версия среды CLR поставляется только с 32-разрядной версией программы установщика, однако 64-разрядная версия среды CLR поставляется и с 32-разрядной, и с 64-разрядной версиями программы установщика. Starting with the .NET Framework version 2.0, the 32-bit version of the common language runtime (CLR) ships with only the 32-bit version of the Installer tool, but the 64-bit version of the CLR ships with both 32-bit and 64-bit versions of the Installer tool. При работе с 64-разрядной средой CLR используйте 32-разрядную программу установщика для установки 32-разрядных сборок, а 64-разрядную программу установщика — для установки 64-разрядных СIL-сборок. When using the 64-bit CLR, use the 32-bit Installer tool to install 32-bit assemblies, and the 64-bit Installer tool to install 64-bit and Microsoft intermediate language (MSIL) assemblies. Обе версии программы установщика ведут себя одинаково. Both versions of the Installer tool behave the same.
Программу Installutil.exe невозможно использовать для развертывания службы Windows, написанной на языке C++, потому что программа Installutil.exe не может распознать встроенный машинный код, созданный компилятором C++. You cannot use Installutil.exe to deploy a Windows service that was created by using C++, because Installutil.exe cannot recognize the embedded native code that is produced by the C++ compiler. При попытке развернуть службу Windows, написанную на языке C++, с помощью программы Installutil.exe возникает исключение, например BadImageFormatException. If you try to deploy a C++ Windows service with Installutil.exe, an exception such as BadImageFormatException will be thrown. Для работы с этим сценарием перенесите код службы в модуль C++ и создайте объект установщика на языке C# или Visual Basic. To work with this scenario, move the service code to a C++ module, and then write the installer object in C# or Visual Basic.
Примеры Examples
Следующая команда выводит описание синтаксиса и параметров команды для программы InstallUtil.exe. The following command displays a description of the command syntax and options for InstallUtil.exe.
Следующая команда выводит описание синтаксиса и параметров команды для программы InstallUtil.exe. The following command displays a description of the command syntax and options for InstallUtil.exe. Она также отображает для myAssembly.exe описание и список параметров, поддерживаемых компонентами установщика, если свойству Installer.HelpText установщика было задано значение текста справки. It also displays a description and list of options supported by the installer components in myAssembly.exe if help text has been assigned to the installer’s Installer.HelpText property.
Следующая команда выполняет компоненты установщика в сборке myAssembly.exe . The following command executes the installer components in the assembly myAssembly.exe .
Следующая команда выполняет компоненты установщика в сборке с помощью ключа /AssemblyName и полного имени. The following command executes the installer components in an assembly by using the /AssemblyName switch and a fully qualified name.
Следующая команда выполняет компоненты установщика в сборке, заданной по имени файла, и в сборке, заданной по строгому имени. The following command executes the installer components in an assembly specified by file name and in an assembly specified by strong name. Обратите внимание, что все сборки, указанные по имени файла, должны предшествовать сборкам, указанным по строгому имени в командной строке, потому что параметр /AssemblyName не может быть переопределен. Note that all assemblies specified by file name must precede assemblies specified by strong name on the command line, because the /AssemblyName option cannot be overridden.
Следующая команда выполняет компоненты программы удаления в сборке myAssembly.exe . The following command executes the uninstaller components in the assembly myAssembly.exe .
Следующая команда выполняет компоненты программы удаления в сборках myAssembly1.exe и myAssembly2.exe . The following command executes the uninstaller components in the assemblies myAssembly1.exe and myAssembly2.exe .
Поскольку позиция параметра /u в командной строке не имеет значения, результат аналогичен выполнению следующей команды. Because the position of the /u option on the command line is not important, this is equivalent to the following command.