Skip to content

Commit

Permalink
Build ChorusMergeModule (#310)
Browse files Browse the repository at this point in the history
* Publish NuGet package for ChorusMergeModule.msm

Addresses #299
  • Loading branch information
papeh authored Dec 8, 2022
1 parent 52c9111 commit c4dd68d
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 25 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,37 @@ jobs:
name: Test Results (${{matrix.os}})
path: "**/TestResults/*.xml"

- name: Checkout Chorus Help # required for Chorus Merge Module
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
with:
repository: sillsdev/chorushelp
path: lib
clean: false # don't delete other files from lib
if: matrix.os == 'windows-latest'

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@34cfbaee7f672c76950673338facd8a73f637506 # v1.1.3
if: matrix.os == 'windows-latest'

# ChorusMergeModule.msm is used by FieldWorks, FLExBridge, and possibly WeSay installers (as of 2022.12).
# CMM must be built after tests have been run, since the fixutf8.pyc files are generated only when the .py files are run.
- name: Build Merge Module
run: msbuild src/Installer/ChorusMergeModule.wixproj
if: matrix.os == 'windows-latest'

- name: Pack Merge Module
run: msbuild src/Installer/ChorusMergeModule.wixproj -t:pack
if: matrix.os == 'windows-latest'

- name: Upload Merge Modules
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: chorus-merge-module
path: |
output/Release/*.msm
output/*.nupkg
if: matrix.os == 'windows-latest'

- name: Pack
run: dotnet pack --no-restore --no-build -c Release

Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build/NuGet.exe
build/nuget.exe
NuGet.exe
nuget.exe
CopyToWeSay.bat
output/
obj/
Expand All @@ -21,6 +21,7 @@ mercurial/
build/old
launchSettings.json
lib/$(Configuration)
*.nupkg
*.resources
*.userprefs
.vs/
Expand Down
96 changes: 96 additions & 0 deletions build/Chorus.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build;Pack">
<PropertyGroup>
<RootDir Condition="'$(teamcity_build_checkoutDir)' == '' And '$(RootDir)'==''">$(MSBuildProjectDirectory)/..</RootDir>
<RootDir Condition="'$(teamcity_build_checkoutDir)' != ''">$(teamcity_build_checkoutDir)</RootDir>
<Solution>Chorus.sln</Solution>
<SolutionPath>$(RootDir)/$(Solution)</SolutionPath>
<ApplicationName Condition="'$(OS)'=='Windows_NT'">ChorusLibrary</ApplicationName>
<ApplicationName Condition="'$(OS)'!='Windows_NT'">Chorus</ApplicationName>
<ApplicationNameLC>chorus</ApplicationNameLC>
<Configuration Condition="'$(Configuration)'==''">Release</Configuration>
<ExtraExcludeCategories Condition="'$(OS)'!='Windows_NT'">KnownMonoIssue,</ExtraExcludeCategories>
<ExtraExcludeCategories Condition="'$(teamcity_version)' != ''">SkipOnTeamCity,SkipOnBuildServer,SkipOnTeamCityRandomTestFailure,$(ExtraExcludeCategories)</ExtraExcludeCategories>
<useNUnit-x86 Condition="'$(OS)'=='Windows_NT'">true</useNUnit-x86>
<useNUnit-x86 Condition="'$(OS)'!='Windows_NT'">false</useNUnit-x86>
<OutputDir>$(RootDir)/output/$(Configuration)</OutputDir>
<TeamCity Condition="'$(teamcity_version)' != ''">true</TeamCity>
<TeamCity Condition="'$(teamcity_version)' == ''">false</TeamCity>

<RestartBuild Condition="!Exists('$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll') Or !Exists('$(RootDir)/packages/NUnit.ConsoleRunner/tools/nunit3-console.exe') Or !Exists('$(RootDir)/packages/BuildDependencyTasks/BuildDependencyTasks.dll')">true</RestartBuild>
<RestartBuild Condition="Exists('$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll') And Exists('$(RootDir)/packages/NUnit.ConsoleRunner/tools/nunit3-console.exe') And Exists('$(RootDir)/packages/BuildDependencyTasks/BuildDependencyTasks.dll')">false</RestartBuild>
</PropertyGroup>

<Import Project="NuGet.targets"/>

<Target Name="RestoreBuildTasks" DependsOnTargets="CheckPrerequisites">
<Message Text="RestartBuild=$(RestartBuild)" />
<Exec Command='$(NuGetCommand) install NUnit.Console -excludeVersion -version 3.11.1 -solutionDirectory "$(RootDir)"' />
<Exec Command='$(NuGetCommand) install SIL.BuildTasks -excludeVersion -version 2.3.2 -solutionDirectory "$(RootDir)"' />
<Exec Command='$(NuGetCommand) install BuildDependencyTasks -excludeVersion -version 0.4.3 -solutionDirectory "$(RootDir)"' />
</Target>

<UsingTask TaskName="MakeWixForDirTree" AssemblyFile="$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll"
Condition="'$(OS)'=='Windows_NT' And Exists('$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll')"/>
<UsingTask TaskName="Archive" AssemblyFile="$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll"
Condition="'$(OS)'!='Windows_NT' And Exists('$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll')"/>
<UsingTask TaskName="FileUpdate" AssemblyFile="$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll" Condition="Exists('$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll')"/>
<UsingTask TaskName="NUnit3" AssemblyFile="$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll" Condition="Exists('$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll')"/>
<UsingTask TaskName="Dependencies" AssemblyFile="$(SolutionDir)/packages/BuildDependencyTasks/BuildDependencyTasks.dll" Condition="Exists('$(RootDir)/packages/BuildDependencyTasks/BuildDependencyTasks.dll')"/>

<!-- Windows installer stuff -->
<Target Name="Installer" DependsOnTargets="CleanInstaller; Build" Condition="'$(OS)'=='Windows_NT'">

<!-- set the version number in the installer configuration program. Perhaps there's a way to just send in the variables rather than this brute-force
changing of the script, but I haven't figured that out. -->

<FileUpdate File="$(RootDir)\src\Installer\ChorusMergeModule.wxs" Regex='Property_ProductVersion = ".*"'
ReplacementText ="Property_ProductVersion = &quot;$(GitVersion_AssemblySemFileVer)&quot;" />
<Message Text="Making Chorus Merge Module Version: $(GitVersion_AssemblySemFileVer)" Importance="high" />

<MSBuild Projects="$(RootDir)\src\Installer\ChorusMergeModule.wixproj"/>

</Target>

<Target Name="ChorusHubInstaller" DependsOnTargets="CleanInstaller;Build" Condition="'$(OS)'=='Windows_NT'">

<!-- set the version number in the installer configuration program. Perhaps there's a way to just send in the variables rather than this brute-force
changing of the script, but I haven't figured that out. -->

<FileUpdate File="$(RootDir)\src\Installer\ChorusHub.wxs" Regex='Property_ProductVersion = ".*"'
ReplacementText="Property_ProductVersion = &quot;$(GitVersion_AssemblySemFileVer)&quot;" />
<FileUpdate File="$(RootDir)\src\Installer\resources\License.rtf" RegEx='COPYRIGHTYEARPLACEHOLDER'
ReplacementText="$([System.DateTime]::Now.ToString(yyyy))" />
<Message Text="Making Chorus Hub installer with version: $(GitVersion_AssemblySemFileVer)" Importance="high" />

<MSBuild Projects="$(RootDir)\src\Installer\ChorusHub.wixproj"/>

</Target>

<Target Name="SignChorusHub" DependsOnTargets="ChorusHubInstaller">
<Message Text="Attempting to sign ChorusHubInstaller.msi" Importance="high" />
<Exec Command='sign "$(RootDir)\output\Release\ChorusHubInstaller.msi" ' />
</Target>

<Target Name="MakeWixForDistFiles" DependsOnTargets="Compile" Condition="'$(OS)'=='Windows_NT'">
<!-- NB: The Exclude argument doesn't seem to be working so you may need to hand edit the GeneratedMercurial.wxs -->
<MakeWixForDirTree
DirectoryReferenceId="mercurial"
ComponentGroupId="Mercurial"
RootDirectory="$(RootDir)\mercurial"
OutputFilePath="$(RootDir)\src\Installer\GeneratedMercurial.wxs"
IgnoreRegExPattern="IGNOREME|\.gitignore"
Exclude="$(RootDir)\mercurial\mercurial.ini;$(RootDir)\mercurial\default.d\cacerts.rc"
MatchRegExPattern=".*">
<Output TaskParameter="OutputFilePath" ItemName="Compile" />
</MakeWixForDirTree>
<MakeWixForDirTree
DirectoryReferenceId="MercurialExtensions"
ComponentGroupId="MercurialExtensions"
RootDirectory="$(RootDir)\MercurialExtensions"
OutputFilePath="$(RootDir)\src\Installer\GeneratedMercurialExtensions.wxs"
IgnoreRegExPattern="IGNOREME|\.gitignore"
MatchRegExPattern=".*">
<Output TaskParameter="OutputFilePath" ItemName="Compile" />
</MakeWixForDirTree>
</Target>
</Project>
15 changes: 15 additions & 0 deletions src/Installer/ChorusMergeModule.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>$PackageId$</id>
<version>$Version$</version>
<description>This is a merge module to set up https://github.com/sillsdev/chorus</description>
<authors>SIL International</authors>
<license type="expression">MIT</license>
<projectUrl>https://github.com/sillsdev/chorus</projectUrl>
<copyright>Copyright © 2010-$Year$ SIL International</copyright>
</metadata>
<files>
<file src="../../output/Release/ChorusMergeModule.msm" target="content"/>
</files>
</package>
40 changes: 21 additions & 19 deletions src/Installer/ChorusMergeModule.wixproj
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- NB: rather than bothering with GitVersion here, we simply expect the version to be lingering in the environment from previous runs.
This is supported by .github/workflows/dotnet.yml -->
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.5</ProductVersion>
<ProductVersion>$(GitVersion_AssemblySemVer)</ProductVersion>
<ProjectGuid>ca0d1ee4-fbea-40fb-a6bc-d9a161e1f2fa</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>ChorusMergeModule</OutputName>
<OutputType>Module</OutputType>
<OutputPath>..\..\output\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<Name>ChorusMergeModule</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>..\..\output\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
<SuppressPdbOutput>True</SuppressPdbOutput>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>..\..\output\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>ProductVersion=$(ProductVersion)</DefineConstants>
<DefineConstants Condition="'$(Configuration)' == 'Debug'">Debug;$(DefineConstants)</DefineConstants>
<SuppressPdbOutput>True</SuppressPdbOutput>
</PropertyGroup>
<ItemGroup>
Expand All @@ -35,12 +31,18 @@
</WixExtension>
</ItemGroup>
<Import Project="$(WixTargetsPath)" />
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Wix.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Import Project="NuGet.targets" />

<!-- Pack NuGet Package -->
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>SIL.Chorus.ChorusMergeModule</PackageId>
<Version>$(GitVersion_NuGetVersion)</Version>
<Year>$([System.DateTime]::Now.ToString(yyyy))</Year>
</PropertyGroup>

<Target Name="pack" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(NuGetCommand) pack ChorusMergeModule.nuspec -Version $(GitVersion_NuGetVersion) -p PackageId=$(PackageId);Year=$(Year)" />
<Copy SourceFiles="$(PackageId).$(Version).nupkg" DestinationFolder="$(MSBuildThisFileDirectory)../../output" />
</Target>
</Project>
5 changes: 1 addition & 4 deletions src/Installer/ChorusMergeModule.wxs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- These variables define the Windows Installer product version, product code and upgrade code. They -->
<!-- will be used later on in this file. -->
<?define Property_ProductVersion = "2.6.3.0" ?>

<!-- good intro to the component vs. file thing, and why each file here is a separate component:
http://blogs.msdn.com/robmen/archive/2003/10/04/56479.aspx -->

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:fire="http://schemas.microsoft.com/wix/FirewallExtension">

<Module Id="ChorusMergeModule" Language="1033" Version="$(var.Property_ProductVersion)">
<Module Id="ChorusMergeModule" Language="1033" Version="$(var.ProductVersion)">
<Package Id="59c055f3-e87e-4101-bc70-87ab07d4f26f" Manufacturer="SIL" InstallerVersion="200" />

<Directory Id="TARGETDIR" Name="SourceDir">
Expand Down
64 changes: 64 additions & 0 deletions src/Installer/NuGet.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NuGetToolsPath>$(MSBuildThisFileDirectory)</NuGetToolsPath>

<!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)nuget.exe</NuGetExePath>

<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono $(NuGetExePath)</NuGetCommand>
<NuGetDownloadUrl>https://dist.nuget.org/win-x86-commandline/latest/nuget.exe</NuGetDownloadUrl>
</PropertyGroup>

<Target Name="CheckPrerequisites">
<!--
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
This effectively acts as a lock that makes sure that the download operation will only happen once and all
parallel builds will have to wait for it to complete.
-->
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)"
Properties="Configuration=NOT_IMPORTANT" />
</Target>

<Target Name="_DownloadNuGet" Condition="!Exists('$(NuGetExePath)')">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition="'$(OS)' == 'Windows_NT'" />
<Exec Command="wget $(NuGetDownloadUrl) || curl -O -L $(NuGetDownloadUrl)"
WorkingDirectory="$(NuGetToolsPath)"
Condition="'$(OS)' != 'Windows_NT'" />
</Target>

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"
Condition=" '$(OS)' == 'Windows_NT' ">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of nuget.exe...");
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
WebClient webClient = new WebClient();
webClient.DownloadFile("$(NuGetDownloadUrl)", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>

0 comments on commit c4dd68d

Please sign in to comment.