-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added build step for generating Windows MSI #1153
Merged
bogdandrutu
merged 1 commit into
open-telemetry:master
from
james-bebbington:windows-msi
Jul 7, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -21,3 +21,7 @@ coverage.txt | |
coverage_all.txt | ||
coverage_old.txt | ||
coverage.html | ||
|
||
# Wix | ||
*.wixobj | ||
*.wixpdb |
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,67 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
<# | ||
.SYNOPSIS | ||
Makefile like build commands for the Collector on Windows. | ||
|
||
Usage: .\make.ps1 <Command> [-<Param> <Value> ...] | ||
Example: .\make.ps1 New-MSI -Config "./my-config.yaml" | ||
.PARAMETER Target | ||
Build target to run (Install-Tools, New-MSI) | ||
#> | ||
Param( | ||
[Parameter(Mandatory=$true, ValueFromRemainingArguments=$true)][string]$Target | ||
) | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
function Install-Tools { | ||
choco install wixtoolset -y | ||
setx /m PATH "%PATH%;C:\Program Files (x86)\WiX Toolset v3.11\bin" | ||
refreshenv | ||
} | ||
|
||
function New-MSI( | ||
[string]$Version="0.0.1", | ||
[string]$Config="./examples/otel-local-config.yaml" | ||
) { | ||
candle -arch x64 -dVersion="$Version" -dConfig="$Config" packaging/msi/opentelemetry-collector.wxs | ||
light opentelemetry-collector.wixobj | ||
Move-Item -Force opentelemetry-collector.msi bin/opentelemetry-collector.msi | ||
} | ||
|
||
function Confirm-MSI { | ||
# ensure system32 is in Path so we can use executables like msiexec & sc | ||
$env:Path += ";C:\Windows\System32" | ||
|
||
# install msi, validate service is installed & running | ||
Start-Process -Wait msiexec "/i `"$pwd\bin\opentelemetry-collector.msi`" /qn" | ||
sc.exe query state=all | findstr "otelcol" | Out-Null | ||
if ($LASTEXITCODE -ne 0) { Throw "otelcol service failed to install" } | ||
|
||
# stop service | ||
Stop-Service otelcol | ||
|
||
# start service | ||
Start-Service otelcol | ||
|
||
# uninstall msi, validate service is uninstalled | ||
Start-Process -Wait msiexec "/x `"$pwd\bin\opentelemetry-collector.msi`" /qn" | ||
sc.exe query state=all | findstr "otelcol" | Out-Null | ||
if ($LASTEXITCODE -ne 1) { Throw "otelcol service failed to uninstall" } | ||
} | ||
|
||
$sb = [scriptblock]::create("$Target") | ||
Invoke-Command -ScriptBlock $sb |
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,56 @@ | ||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> | ||
<Product Id="*" UpgradeCode="B7C263DD-95A5-436A-A025-DCA5200C2BE3" Name="OpenTelemetry Collector" Version="$(var.Version)" Manufacturer="OpenTelemetry" Language="1033"> | ||
<Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package"/> | ||
<Media Id="1" Cabinet="product.cab" EmbedCab="yes"/> | ||
<Icon Id="ProductIcon" SourceFile="./packaging/msi/opentelemetry.ico"/> | ||
<Property Id="ARPPRODUCTICON" Value="ProductIcon"/> | ||
<Property Id="ARPHELPLINK" Value="https://opentelemetry.io/"/> | ||
<Property Id="ARPURLINFOABOUT" Value="https://opentelemetry.io/"/> | ||
<Property Id="ARPNOREPAIR" Value="1"/> | ||
<Property Id="ARPNOMODIFY" Value="1"/> | ||
|
||
<Feature Id="Feature" Level="1"> | ||
<ComponentRef Id="ApplicationComponent"/> | ||
</Feature> | ||
|
||
<Directory Id="TARGETDIR" Name="SourceDir"> | ||
<Directory Id="ProgramFiles64Folder"> | ||
<Directory Id="INSTALLDIR" Name="OpenTelemetry Collector"> | ||
<Component Id="ApplicationComponent" Guid="1207C3C4-1830-4DC8-8A7B-2BD7DBE45BC3"> | ||
<!-- Files to include --> | ||
<File Id="ExecutableFile" Name="otelcol.exe" KeyPath="yes" Source="./bin/otelcol_windows_amd64.exe"/> | ||
<File Id="DefaultConfigFile" Name="config.yaml" Source="$(var.Config)" /> | ||
<!-- Since we may have overwritten the config file (see below), we need to explicitly remove it on uninstall --> | ||
<RemoveFile Id="RemoveConfigFile" Name="config.yaml" On="uninstall" /> | ||
|
||
<ServiceInstall | ||
Id="Sevice" | ||
Name="otelcol" | ||
DisplayName="OpenTelemetry Collector" | ||
Description="Collects, processes, and exports telemetry from various configurable sources." | ||
Type="ownProcess" | ||
Vital="yes" | ||
Start="auto" | ||
Account="LocalSystem" | ||
ErrorControl="normal" | ||
Arguments=" --config="[INSTALLDIR]config.yaml"" | ||
Interactive="no" /> | ||
<ServiceControl | ||
Id="StartStopRemoveService" | ||
Name="otelcol" | ||
Start="install" | ||
Stop="both" | ||
Remove="uninstall" | ||
Wait="yes" /> | ||
</Component> | ||
</Directory> | ||
</Directory> | ||
</Directory> | ||
|
||
<!-- If CONFIG is supplied as a custom argument when installing, overwrite config.yaml with the specified file --> | ||
<CustomAction Id="CopyConfig" ExeCommand="xcopy /y "[CONFIG]" "[INSTALLDIR]config.yaml*"" Directory="INSTALLDIR" Impersonate="no" Execute="deferred" Return="check" /> | ||
<InstallExecuteSequence> | ||
<Custom Action="CopyConfig" After="InstallFiles">CONFIG AND NOT Installed</Custom> | ||
</InstallExecuteSequence> | ||
</Product> | ||
</Wix> |
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@owais
I think this PR is ready to be merged, however, should I make the same change here as you made in https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/384/files and replace build with cross-compile? (I had changed this dependency to speed up the overall build time since this PR adds another step that's dependent on cross-compile)