Skip to content

Commit

Permalink
Merge pull request #495: [HOTFIX] Fix macOS build around Git installe…
Browse files Browse the repository at this point in the history
…r package

This should also fix the microsoft.scalar-release pipeline.

See #494 for the version into `main`.

After many attempts, I now have this working with [the `microsoft.scalar-release` build in Azure Pipelines](https://dev.azure.com/mseng/Scalar/_build/results?buildId=14679562&view=results)
  • Loading branch information
derrickstolee authored Mar 19, 2021
2 parents 90980dc + 55fa7c5 commit 013f6a7
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 14 deletions.
9 changes: 9 additions & 0 deletions .azure-pipelines/templates/osx/build-and-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ steps:
displayName: Delete previous build outputs
continueOnError: true

- script: |
GIT_VERSION=$(grep '<GitPackageVersion>' Directory.Build.props | grep -Eo '[0-9.]+(-\w+)*')
mkdir ../out
cd ../out
dotnet new classlib -n Scalar.GitInstaller
cd Scalar.GitInstaller
dotnet add Scalar.GitInstaller.csproj package "GitForMac.GVFS.Installer" --package-directory . --version "$GIT_VERSION" --source "https://pkgs.dev.azure.com/gvfs/ci/_packaging/Dependencies/nuget/v3/index.json"
displayName: Setup Git installer
- script: Scripts/Mac/BuildScalarForMac.sh $(configuration) $(majorAndMinorVersion).$(revision)
displayName: Build Scalar ($(configuration))

Expand Down
3 changes: 2 additions & 1 deletion .azure-pipelines/templates/osx/pack.signed/step5-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ steps:

- script: |
GCMURL=$(xmllint --xpath '//Project/PropertyGroup/GcmCoreOSXPackageUrl/text()' Directory.Build.props) || exit 1
Scalar.Installer.Mac/dist.sh "$(Build.ArtifactStagingDirectory)/package"/Scalar*.pkg "$(Build.ArtifactStagingDirectory)/gitformacpkg"/*.pkg "$GCMURL" "Scalar.Installer.Mac/InstallScalar.template.sh" "$(Build.ArtifactStagingDirectory)/dist"
GIT_VERSION=$(grep '<GitPackageVersion>' Directory.Build.props | grep -Eo '[0-9.]+(-\w+)*')
Scalar.Installer.Mac/dist.sh "$(Build.ArtifactStagingDirectory)/package"/Scalar*.pkg "$GIT_VERSION" "$GCMURL" "Scalar.Installer.Mac/InstallScalar.template.sh" "$(Build.ArtifactStagingDirectory)/dist"
displayName: Create distribution script
- task: PublishPipelineArtifact@1
Expand Down
3 changes: 3 additions & 0 deletions .azure-pipelines/templates/win/build-and-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ steps:
displayName: Delete previous build outputs
continueOnError: true

- script: $(Build.Repository.LocalPath)\.azure-pipelines\templates\win\install-git-package.bat
displayName: Setup Git installer

- script: $(Build.Repository.LocalPath)\Scripts\BuildScalarForWindows.bat $(configuration) $(majorAndMinorVersion).$(revision)
displayName: Build Scalar ($(configuration))

Expand Down
1 change: 1 addition & 0 deletions .azure-pipelines/templates/win/install-git-package.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"C:\Program Files\Git\bin\bash.exe" .azure-pipelines/templates/win/install-git-package.sh
8 changes: 8 additions & 0 deletions .azure-pipelines/templates/win/install-git-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

GIT_VERSION=$(grep '<GitPackageVersion>' Directory.Build.props | grep -Eo '[0-9.]+(-\w+)*')
mkdir ../out
cd ../out
dotnet new classlib -n Scalar.GitInstaller
cd Scalar.GitInstaller
dotnet add Scalar.GitInstaller.csproj package "GitForWindows.GVFS.Installer" --package-directory . --version "$GIT_VERSION" --source "https://pkgs.dev.azure.com/gvfs/ci/_packaging/Dependencies/nuget/v3/index.json"
7 changes: 5 additions & 2 deletions Scalar.Installer.Mac/Scalar.Installer.Mac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@
<ItemGroup>
<ScriptTemplate Include="$(MSBuildThisFileDirectory)InstallScalar.template.sh" />
<ScalarPackage Include="$(PackageOutputPath)*.pkg" />
<GitPackage Include="$(PkgGitForMac_GVFS_Installer)\tools\*.pkg" />
</ItemGroup>

<!-- Build the distribution script -->
<Exec Command="$(MSBuildProjectDirectory)/dist.sh '@(ScalarPackage)' '@(GitPackage)' '$(GcmCoreOSXPackageUrl)' '@(ScriptTemplate)' '$(DistributionOutputPath)'"/>
<Exec Command="$(MSBuildProjectDirectory)/dist.sh '@(ScalarPackage)' '$(GitPackageVersion)' '$(GcmCoreOSXPackageUrl)' '@(ScriptTemplate)' '$(DistributionOutputPath)'"/>

<ItemGroup>
<GitPackage Include="../../out/Scalar.Installer.Mac/dist/$(Configuration)/Git/*.pkg" LinkBase="Git" />
</ItemGroup>
</Target>

<Target Name="_Clean" AfterTargets="Clean">
Expand Down
20 changes: 10 additions & 10 deletions Scalar.Installer.Mac/dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ if [ -z "${SCALAR_PKG}" ]; then
exit 1
fi

GIT_PKG=$2
if [ -z "${GIT_PKG}" ]; then
GIT_PKG_VERSION=$2
if [ -z "${GIT_PKG_VERSION}" ]; then
echo "Error: Git installer package not specified"
exit 1
fi
Expand Down Expand Up @@ -46,14 +46,14 @@ function CopyScalar()
function CopyGit()
{
GIT_DESTINATION="${OUT_DIR}/Git"

if [ ! -f "${GIT_PKG}" ] ; then
echo "Error: Could not find Git for Mac package at ${GIT_PKG}."
exit 1
fi

mkdir -p "${GIT_DESTINATION}" || exit 1
cp -Rf "${GIT_PKG}" "${GIT_DESTINATION}" || exit 1
nuget install GitForMac.GVFS.Installer -DependencyVersion "$GIT_PKG_VERISON" -Source "https://pkgs.dev.azure.com/gvfs/ci/_packaging/Dependencies/nuget/v3/index.json" -OutputDirectory "${OUT_DIR}"
unzip "${OUT_DIR}/GitForMac.GVFS.Installer.$GIT_PKG_VERSION/GitForMac.GVFS.Installer.$GIT_PKG_VERSION.nupkg"
rm -rf "$GIT_DESTINATION"
mv -v "${OUT_DIR}/GitForMac.GVFS.Installer.$GIT_PKG_VERSION/tools/" "$GIT_DESTINATION/"
rm "$GIT_DESTINATION/*dmg"
GIT_PKG="$GIT_DESTINATION/*pkg"
rm -rf "${OUT_DIR}/GitForMac.GVFS.Installer.$GIT_PKG_VERSION/"
ls -alR "${OUT_DIR}"
}

function CopyGcmCore()
Expand Down
2 changes: 1 addition & 1 deletion Scalar.Installer.Windows/Scalar.Installer.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<!-- Build the distribution script -->
<ItemGroup>
<ScalarPackage Include="$(InstallerOutputPath)\*.exe" LinkBase="Scalar" />
<GitPackage Include="$(PkgGitForWindows_GVFS_Installer)\tools\*.exe" LinkBase="Git" />
<GitPackage Include="..\..\out\Scalar.GitInstaller\gitforwindows.gvfs.installer\2*\tools\*.exe" LinkBase="Git" />
</ItemGroup>
<Copy SourceFiles="@(ScalarPackage);@(GitPackage)"
DestinationFolder="$(DistributionOutputPath)%(LinkBase)"
Expand Down

0 comments on commit 013f6a7

Please sign in to comment.