-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare MSI installer using Pyinstaller and WIX Toolset (#1007)
# Description msi installer ![image](https://github.com/microsoft/promptflow/assets/26239730/013ac830-0518-497e-b61d-5d90550c80d0) directory structure after installing ![image](https://github.com/microsoft/promptflow/assets/26239730/9c4299be-0d53-4a93-b387-6e9d7f5ec561) app in "Programs and Features" / "services" ![image](https://github.com/microsoft/promptflow/assets/26239730/c2886dbe-517f-4108-bde6-32259cbb41ed) ![image](https://github.com/microsoft/promptflow/assets/26239730/29a2dd9f-d21f-470a-acff-eda40d020781) pf command in CLI ![image](https://github.com/microsoft/promptflow/assets/26239730/bf3c64eb-ab96-4b0c-b102-6bb18b27fddc) system path environment ![image](https://github.com/microsoft/promptflow/assets/26239730/eafb25b7-d72b-4e4f-9346-6bd6c5a5a2e2) Please add an informative description that covers that changes made by the pull request and link all relevant issues. # All Promptflow Contribution checklist: - [ ] **The pull request does not introduce [breaking changes].** - [ ] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [ ] **I have read the [contribution guidelines](../CONTRIBUTING.md).** - [ ] **Create an issue and link to the pull request to get dedicated review from promptflow team. Learn more: [suggested workflow](../CONTRIBUTING.md#suggested-workflow).** ## General Guidelines and Best Practices - [ ] Title of the pull request is clear and informative. - [ ] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### Testing Guidelines - [ ] Pull request includes test coverage for the included changes. --------- Co-authored-by: Ying Chen <2601502859@qq.com> Co-authored-by: Clement Wang <47586720+wangchao1230@users.noreply.github.com>
- Loading branch information
1 parent
7a29b13
commit 3479c16
Showing
12 changed files
with
628 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
**/windows/scripts/build | ||
**/windows/scripts/dist | ||
**/windows/wix | ||
**/windows/out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Building the Windows MSI Installer | ||
======================== | ||
|
||
This document provides instructions on creating the MSI installer. | ||
|
||
Prerequisites | ||
------------- | ||
|
||
1. Turn on the '.NET Framework 3.5' Windows Feature (required for WIX Toolset). | ||
2. Install 'Microsoft Build Tools 2015'. | ||
https://www.microsoft.com/download/details.aspx?id=48159 | ||
3. You need to have curl.exe, unzip.exe and msbuild.exe available under PATH. | ||
4. Install 'WIX Toolset build tools' following the instructions below. | ||
- Enter the directory where the README is located (`cd scripts/installer/windows`), `mkdir wix` and `cd wix`. | ||
- `curl --output wix-archive.zip https://azurecliprod.blob.core.windows.net/msi/wix310-binaries-mirror.zip` | ||
- `unzip wix-archive.zip` and `del wix-archive.zip` | ||
5. We recommend creating a clean virtual Python environment and installing all dependencies using src/promptflow/setup.py. | ||
- `python -m venv venv` | ||
- `venv\Scripts\activate` | ||
- `pip install promptflow[azure,executable] promptflow-tools` | ||
|
||
|
||
Building | ||
-------- | ||
1. `cd scripts/installer/windows/scripts` and run `pyinstaller promptflow.spec`. | ||
2. `cd scripts/installer/windows` and Run `msbuild /t:rebuild /p:Configuration=Release /p:Platform=x64 promptflow.wixproj`. | ||
3. The unsigned MSI will be in the `scripts/installer/windows/out` folder. | ||
|
||
Notes | ||
-------- | ||
- If you encounter "Access is denied" error when running promptflow. Please follow the [link](https://learn.microsoft.com/en-us/microsoft-365/security/defender-endpoint/attack-surface-reduction-rules-deployment-implement?view=o365-worldwide#customize-attack-surface-reduction-rules) to add the executable to the Windows Defender Attack Surface Reduction (ASR) rule. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> | ||
|
||
<?define ProductVersion="1.0.0.0" ?> | ||
|
||
<?define ProductName = "promptflow" ?> | ||
<?define ProductDescription = "Command-line tools for promptflow." ?> | ||
<?define ProductAuthor = "Microsoft Corporation" ?> | ||
<?define ProductResources = ".\resources\" ?> | ||
<?define UpgradeCode32 = "8b748161-e07a-48f2-8cdf-401480df4694" ?> | ||
<?define PromptflowServiceGuid = "d9363a28-693c-4b12-bf0a-30e4b37e9951" ?> | ||
|
||
<?if $(var.Platform) = "x64" ?> | ||
<?define PromptflowCliRegistryGuid = "0efd984f-9eec-425b-b230-a3994b69649a" ?> | ||
<?define PromptflowCliVersionGuid = "d4e99207-77be-4bdf-a430-b08632c5aa2b" ?> | ||
<?define PromptflowSystemPathGuid = "4c321045-d4e0-4446-bda4-8c19eaa42af1" ?> | ||
<?define ProgramFilesFolder = "ProgramFiles64Folder" ?> | ||
<?define RemovePromptflowFolderGuid = "ee843aa5-2b72-4958-be84-53dbac17efc7" ?> | ||
<?define UpgradeCode = "772aa21f-f8d4-4771-b910-1dbce3f1920c" ?> | ||
<?define Architecture = "64-bit" ?> | ||
|
||
<?elseif $(var.Platform) = "x86" ?> | ||
<?define PromptflowCliRegistryGuid = "7c2c792d-c395-44a1-8222-8e4ea006abb9" ?> | ||
<?define PromptflowCliVersionGuid = "f706b208-a15d-4ae7-9185-cfcc43656570" ?> | ||
<?define PromptflowSystemPathGuid = "9661fe6a-ff48-4e7c-a60d-fc34c2d06ef3" ?> | ||
<?define ProgramFilesFolder = "ProgramFilesFolder" ?> | ||
<?define RemovePromptflowFolderGuid = "588ca5e1-38c6-4659-8b38-762df7ed5b28" ?> | ||
<?define UpgradeCode = $(var.UpgradeCode32) ?> | ||
<?define Architecture = "32-bit" ?> | ||
|
||
<?else ?> | ||
<?error Unsupported platform "$(var.Platform)" ?> | ||
<?endif ?> | ||
|
||
<Product Id="*" Name="$(var.ProductName) ($(var.Architecture))" Language="1033" Version="$(var.ProductVersion)" Manufacturer="$(var.ProductAuthor)" UpgradeCode="$(var.UpgradeCode)"> | ||
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> | ||
|
||
<Upgrade Id="$(var.UpgradeCode)"> | ||
<UpgradeVersion Property="WIX_UPGRADE_DETECTED" Maximum="$(var.ProductVersion)" IncludeMaximum="no" MigrateFeatures="yes" /> | ||
<UpgradeVersion Property="WIX_DOWNGRADE_DETECTED" Minimum="$(var.ProductVersion)" IncludeMinimum="no" OnlyDetect="yes" /> | ||
</Upgrade> | ||
<InstallExecuteSequence> | ||
<RemoveExistingProducts After="InstallExecute" /> | ||
</InstallExecuteSequence> | ||
|
||
|
||
<!-- New product architectures should upgrade the original x86 product - even of the same version. --> | ||
<?if $(var.UpgradeCode) != $(var.UpgradeCode32) ?> | ||
<Upgrade Id="$(var.UpgradeCode32)"> | ||
<UpgradeVersion Property="WIX_X86_UPGRADE_DETECTED" Maximum="$(var.ProductVersion)" IncludeMaximum="yes" MigrateFeatures="yes" /> | ||
<UpgradeVersion Property="WIX_X86_DOWNGRADE_DETECTED" Minimum="$(var.ProductVersion)" IncludeMinimum="no" OnlyDetect="yes" /> | ||
</Upgrade> | ||
<Condition Message="A newer version of $(var.ProductName) is already installed.">NOT (WIX_DOWNGRADE_DETECTED OR WIX_X86_DOWNGRADE_DETECTED)</Condition> | ||
<?else ?> | ||
<Condition Message="A newer version of $(var.ProductName) is already installed.">NOT WIX_DOWNGRADE_DETECTED</Condition> | ||
<?endif ?> | ||
|
||
<Media Id="1" Cabinet="promptflow.cab" EmbedCab="yes" CompressionLevel="high" /> | ||
|
||
<Icon Id="PromptflowIcon" SourceFile="$(var.ProductResources)logo32.ico" /> | ||
|
||
<Property Id="ARPPRODUCTICON" Value="PromptflowIcon" /> | ||
<Property Id="ARPHELPLINK" Value="https://microsoft.github.io/promptflow/how-to-guides/quick-start.html" /> | ||
<Property Id="ARPURLINFOABOUT" Value="https://microsoft.github.io/promptflow/how-to-guides/quick-start.html" /> | ||
<Property Id="ARPURLUPDATEINFO" Value="https://microsoft.github.io/promptflow/how-to-guides/quick-start.html" /> | ||
<Property Id="MSIFASTINSTALL" Value="7" /> | ||
<Property Id="ApplicationFolderName" Value="promptflow" /> | ||
<Property Id="WixAppFolder" Value="WixPerMachineFolder" /> | ||
|
||
<Feature Id="ProductFeature" Title="promptflow" Level="1" AllowAdvertise="no"> | ||
<ComponentGroupRef Id="ProductComponents" /> | ||
</Feature> | ||
|
||
<!--Custom action to propagate path env variable change--> | ||
<CustomActionRef Id="WixBroadcastEnvironmentChange" /> | ||
|
||
<!-- User Interface --> | ||
<WixVariable Id="WixUILicenseRtf" Value="$(var.ProductResources)CLI_LICENSE.rtf"/> | ||
|
||
<UIRef Id="WixUI_Minimal"/> | ||
<UIRef Id="WixUI_ErrorProgressText"/> | ||
|
||
<!-- Show message to restart any terminals only if the PATH is changed --> | ||
<CustomAction Id="Set_WIXUI_EXITDIALOGOPTIONALTEXT" Property="WIXUI_EXITDIALOGOPTIONALTEXT" Value="Please close and reopen any active terminal window to use prompt flow." /> | ||
<InstallUISequence> | ||
<Custom Action="Set_WIXUI_EXITDIALOGOPTIONALTEXT" After="CostFinalize">NOT Installed AND NOT WIX_UPGRADE_DETECTED</Custom> | ||
</InstallUISequence> | ||
|
||
</Product> | ||
|
||
<Fragment> | ||
<Directory Id="TARGETDIR" Name="SourceDir"> | ||
<Directory Id="$(var.ProgramFilesFolder)"> | ||
<Directory Id="DynamicCliDir" Name="promptflow" /> | ||
</Directory> | ||
</Directory> | ||
</Fragment> | ||
|
||
<Fragment> | ||
<ComponentGroup Id="PromptflowCliSettingsGroup"> | ||
<Component Id="RemovePromptflowFolder" Directory="DynamicCliDir" Guid="$(var.RemovePromptflowFolderGuid)"> | ||
<RemoveFolder Id="DynamicCliDir" On="uninstall" /> | ||
</Component> | ||
|
||
<Component Id="PromptflowSystemPath" Directory="DynamicCliDir" Guid="$(var.PromptflowSystemPathGuid)"> | ||
<Environment Id="PromptflowAddedToPATH" | ||
Name="PATH" | ||
Value="[DynamicCliDir]" | ||
Permanent="no" | ||
Part="first" | ||
Action="set" | ||
System="yes" /> | ||
<CreateFolder /> | ||
</Component> | ||
<Component Id="PromptflowCliRegistry" | ||
Directory="DynamicCliDir" | ||
Guid="$(var.PromptflowCliRegistryGuid)"> | ||
<RegistryValue Root="HKCU" | ||
Key="Software\Microsoft\$(var.ProductName)" | ||
Name="installed" | ||
Type="integer" | ||
Value="1" | ||
KeyPath="yes"/> | ||
</Component> | ||
<Component Id="PromptflowCliVersion" | ||
Directory="DynamicCliDir" | ||
Guid="$(var.PromptflowCliVersionGuid)"> | ||
<RegistryValue Root="HKLM" | ||
Key="Software\Microsoft\$(var.ProductName)" | ||
Name="version" | ||
Type="string" | ||
Value="$(var.ProductVersion)" | ||
KeyPath="yes"/> | ||
</Component> | ||
<Component Id="PromptflowService" Directory="DynamicCliDir" Guid="$(var.PromptflowServiceGuid)"> | ||
<File Id="PromptflowServiceEXE" Source="scripts\dist\promptflow\pfs.exe" KeyPath="yes" /> | ||
<ServiceInstall Id="ServiceInstaller" Name="PromptflowService" DisplayName="Prompt Flow Service" Description="Provides run and connection management for prompt flow" Start="auto" Type="ownProcess" ErrorControl="normal" /> | ||
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="PromptflowService" Wait="no" /> | ||
</Component> | ||
|
||
</ComponentGroup> | ||
|
||
<ComponentGroup Id="ProductComponents"> | ||
<ComponentGroupRef Id="PromptflowCliComponentGroup"/> | ||
<ComponentGroupRef Id="PromptflowCliSettingsGroup"/> | ||
</ComponentGroup> | ||
</Fragment> | ||
</Wix> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<!-- Project --> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
<ProductVersion>3.10</ProductVersion> | ||
<ProjectGuid>04ff6707-750d-4474-89b3-7922c84721be</ProjectGuid> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<OutputName>promptflow</OutputName> | ||
<OutputType>Package</OutputType> | ||
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath> | ||
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath> | ||
</PropertyGroup> | ||
<!-- Local WiX --> | ||
<PropertyGroup> | ||
<LocalWixRoot>wix</LocalWixRoot> | ||
<WixToolPath>$(MSBuildThisFileDirectory)$(LocalWixRoot)</WixToolPath> | ||
<WixTargetsPath Condition="Exists('$(WixToolPath)\Wix.targets')">$(WixToolPath)\Wix.targets</WixTargetsPath> | ||
<WixTasksPath Condition="Exists('$(WixToolPath)\wixtasks.dll')">$(WixToolPath)\wixtasks.dll</WixTasksPath> | ||
<PromptflowSource>scripts\dist\promptflow</PromptflowSource> | ||
<LinkerAdditionalOptions>-fv</LinkerAdditionalOptions> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
<OutputPath>out\$(Configuration)\</OutputPath> | ||
<IntermediateOutputPath>out\obj\$(Configuration)\</IntermediateOutputPath> | ||
<DefineConstants>Debug;PromptflowSource=$(PromptflowSource)</DefineConstants> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
<OutputPath>out\</OutputPath> | ||
<IntermediateOutputPath>out\obj\$(Configuration)\</IntermediateOutputPath> | ||
<DefineConstants>PromptflowSource=$(PromptflowSource)</DefineConstants> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> | ||
<OutputPath>out\$(Configuration)\</OutputPath> | ||
<IntermediateOutputPath>out\obj\$(Configuration)\</IntermediateOutputPath> | ||
<DefineConstants>Debug;PromptflowSource=$(PromptflowSource)</DefineConstants> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' "> | ||
<OutputPath>out\</OutputPath> | ||
<IntermediateOutputPath>out\obj\$(Configuration)\</IntermediateOutputPath> | ||
<DefineConstants>PromptflowSource=$(PromptflowSource)</DefineConstants> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="out\promptflow.wxs"> | ||
<Link>promptflow.wxs</Link> | ||
</Compile> | ||
<Compile Include="product.wxs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include=".\resources\logo_pf.png" /> | ||
</ItemGroup> | ||
<!-- UI --> | ||
<ItemGroup> | ||
<WixExtension Include="WixUIExtension"> | ||
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath> | ||
<Name>WixUIExtension</Name> | ||
</WixExtension> | ||
<WixExtension Include="WixUtilExtension"> | ||
<HintPath>$(WixExtDir)\WixUtilExtension.dll</HintPath> | ||
<Name>WixUtilExtension</Name> | ||
</WixExtension> | ||
</ItemGroup> | ||
<Import Project="$(WixTargetsPath)" /> | ||
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\wix.targets') " /> | ||
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' "> | ||
<Error Text="The WiX Toolset v3.10 build tools must be installed to build this project. To download the WiX Toolset, see https://wixtoolset.org/releases/v3.10/stable" /> | ||
</Target> | ||
<Target Name="BeforeBuild"> | ||
<HeatDirectory Directory="$(PromptflowSource)" ToolPath="$(WixToolPath)" AutogenerateGuids="true" ComponentGroupName="PromptflowCliComponentGroup" SuppressRootDirectory="true" DirectoryRefId="DynamicCliDir" OutputFile="out\promptflow.wxs" PreprocessorVariable="var.PromptflowSource" /> | ||
</Target> | ||
</Project> |
Oops, something went wrong.