Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"edge-js": "10.3.1",
"ffi-napi": "2.4.3",
"gpii-universal": "0.3.0-dev.20200128T170154Z.eaac9112e",
"gpii-universal": "JavierJF/universal#GPII-3810",
"@pokusew/pcsclite": "0.4.18",
"ref": "1.3.4",
"ref-struct": "1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion provisioning/Npm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Import-Module "$($originalBuildScriptPath)/Provisioning.psm1" -Force

$npm = "npm" -f $env:SystemDrive

Invoke-Command $npm "config set msvs_version 2015 --global"
Invoke-Command $npm "config set msvs_version 2017 --global"
Invoke-Command $npm "install grunt-cli -g"
Invoke-Command $npm "install testem -g"
refreshenv
Expand Down
22 changes: 18 additions & 4 deletions provisioning/NpmInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,35 @@ $VerbosePreference = "continue"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$rootDir = Split-Path -Parent $scriptDir

if (${Env:ProgramFiles(x86)}) {
$programFilesX86Path = ${Env:ProgramFiles(x86)}
} else {
# This is required for compatibility with Intel 32-bit systems (since the ProgramFiles(x86) environment variable does not exist on 32-bit Windows)
$programFilesX86Path = ${Env:ProgramFiles}
}
$programFilesPath = ${Env:ProgramFiles}

# Include main Provisioning module.
Import-Module (Join-Path $scriptDir 'Provisioning.psm1') -Force -Verbose

$msbuild = Get-MSBuild "4.0"
# For Microsoft's build tools, we will accept any version >=15.0 and <16.0 (i.e. VS2017)
$visualStudioVersion = "[15.0,16.0)"

# Capture the full file path of MSBuild
$msbuild = Get-MSBuild $visualStudioVersion

# Capture the full file path of the C# compiler
$csc = Get-CSharpCompiler $visualStudioVersion

# Build the settings helper
$settingsHelperDir = Join-Path $rootDir "settingsHelper"
Invoke-Command $msbuild "SettingsHelper.sln /p:Configuration=Release /p:Platform=`"Any CPU`" /p:FrameworkPathOverride=`"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1`"" $settingsHelperDir
Invoke-Command $msbuild "SettingsHelper.sln /p:Configuration=Release /p:Platform=`"Any CPU`" /p:FrameworkPathOverride=`"$($programFilesX86Path)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1`"" $settingsHelperDir

$volumeControlDir = Join-Path $rootDir "gpii\node_modules\nativeSettingsHandler\nativeSolutions\VolumeControl"
Invoke-Command $msbuild "VolumeControl.sln /p:Configuration=Release /p:Platform=`"x86`" /p:FrameworkPathOverride=`"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1`"" $volumeControlDir
Invoke-Command $msbuild "VolumeControl.sln /p:Configuration=Release /p:Platform=`"x86`" /p:FrameworkPathOverride=`"$($programFilesX86Path)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1`"" $volumeControlDir

# Build the process test helper
$testProcessHandlingDir = Join-Path $rootDir "gpii\node_modules\processHandling\test"
$csc = Join-Path -Path (Split-Path -Parent $msbuild) csc.exe
Invoke-Command $csc "/target:exe /out:test-window.exe test-window.cs" $testProcessHandlingDir

# Build the Windows Service
Expand Down
68 changes: 61 additions & 7 deletions provisioning/Provisioning.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,74 @@ Function Invoke-Command {
Function Get-MSBuild {
Param (
[Parameter(Mandatory=$true)]
[string] $version
[string] $visualStudioVersion
)

# TODO: Check version validity.
# Valid versions are [2.0, 3.5, 4.0]
# Find the path to vswhere (which installed with Visual Studio 2017 or Build Tools 2017 or later)
$vswhere = Get-VSWhere

$dotNetVersion = $version
$regKey = "HKLM:\software\Microsoft\MSBuild\ToolsVersions\$dotNetVersion"
$regProperty = "MSBuildToolsPath"
if (!$vswhere) {
throw "Visual Studio $($visualStudioVersion) or Build Tools $($visualStudioVersion) were not found."
}

$msbuild = Join-Path -path (Get-ItemProperty $regKey).$regProperty -childpath "msbuild.exe"
# courtesy of Microsoft: https://github.com/microsoft/vswhere/wiki/Find-MSBuild/62adac8eb22431fa91d94e03503d76d48a74939c
$path = &$vswhere -version $visualStudioVersion -products * -requires Microsoft.Component.MSBuild -property installationPath
if ($path) {
$msbuild = Join-Path $path 'MSBuild\Current\Bin\MSBuild.exe'
if (-not (test-path $msbuild)) {
$msbuild = join-path $path 'MSBuild\15.0\Bin\MSBuild.exe'
if (-not (test-path $msbuild)) {
throw "MSBuild from Visual Studio $($visualStudioVersion) or Build Tools $($visualStudioVersion) could not be found"
}
}
}

return $msbuild
}

Function Get-CSharpCompiler {
Param (
[Parameter(Mandatory=$true)]
[string] $visualStudioVersion
)

# Find the path to vswhere (which installed with Visual Studio 2017 or Build Tools 2017 or later)
$vswhere = Get-VSWhere

if (!$vswhere) {
throw "Visual Studio $($visualStudioVersion) or Build Tools $($visualStudioVersion) were not found."
}

# adapted from: https://github.com/microsoft/vswhere/wiki/Find-MSBuild/62adac8eb22431fa91d94e03503d76d48a74939c
$path = &$vswhere -version $visualStudioVersion -products * -requires Microsoft.VisualStudio.Component.Roslyn.Compiler -property installationPath
if ($path) {
$csc = Join-Path $path 'MSBuild\Current\Bin\Roslyn\csc.exe'
if (-not (test-path $csc)) {
$csc = join-path $path 'MSBuild\15.0\Bin\Roslyn\csc.exe'
if (-not (test-path $csc)) {
throw "csc from Visual Studio $($visualStudioVersion) or Build Tools $($visualStudioVersion) could not be found"
}
}
}

return $csc
}

Function Get-VSWhere {
# NOTE: this function is compatible with Visual Studio 2017+

# Valid Visual Studio versions options are [15.0, "[15.0,16.0)", etc.]

# Find the path to vswhere (which installed with Visual Studio 2017 or Build Tools 2017 or later)
if (${Env:ProgramFiles(x86)}) {
$vswhere = Join-Path ${Env:ProgramFiles(x86)} "Microsoft Visual Studio\Installer\vswhere.exe"
} else {
$vswhere = Join-Path ${Env:ProgramFiles} "Microsoft Visual Studio\Installer\vswhere.exe"
}

return $vswhere
}

Function Invoke-Environment {
Param (
[Parameter(Mandatory=$true)]
Expand Down Expand Up @@ -108,5 +161,6 @@ Function Add-Path {

Export-ModuleMember -Function Invoke-Command
Export-ModuleMember -Function Get-MSBuild
Export-ModuleMember -Function Get-CSharpCompiler
Export-ModuleMember -Function Invoke-Environment
Export-ModuleMember -Function Add-Path