Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Duco
committed
May 7, 2018
1 parent
3ebbb3a
commit 2919fbd
Showing
17 changed files
with
314 additions
and
47 deletions.
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
Copyright 2018 Duco Winterwerp | |||
|
|||
MIT License | |||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |||
|
|||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
before_build: | |||
- cmd: dotnet --version | |||
- ps: Get-ChildItem -Path "C:\Program Files\dotnet\sdk" | |||
- ps: scripts\patch_versions.ps1 | |||
|
|||
environment: | |||
access_token: | |||
secure: Zcoti9GsS4Y1t12qVcWhfDXMJLW8QLt4SdeQi8VKUFBtd/gVyWsZlLXDOHLP8i5U | |||
|
|||
branches: | |||
only: | |||
- master | |||
- dev | |||
|
|||
build_script: | |||
- ps: scripts\build.ps1 | |||
|
|||
test: off | |||
|
|||
artifacts: | |||
- path: src\Placeholder\bin\release\netcoreapp2.0\win10-x64\publish\placeholder_*.exe | |||
name: armyknife-windows | |||
type: zip | |||
|
|||
deploy: | |||
release: $(versionString) | |||
provider: GitHub | |||
auth_token: $(access_token) | |||
draft: true | |||
on: | |||
branch: master |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,50 @@ | |||
$ErrorActionPreference = 'Stop' | |||
|
|||
$rootFolder = Join-Path -Path $PSScriptRoot ".." | |||
$srcFolder = Join-Path -Path $rootFolder "src" | |||
$mainProjectFile = Join-Path $srcFolder "Placeholder\Placeholder.csproj" | |||
$solutionFile = Join-Path -Path $srcFolder "Placeholder.sln" | |||
|
|||
$nsisPath = "C:\Program Files (x86)\NSIS\Bin" | |||
|
|||
. "$PSScriptRoot\functions.ps1" | |||
|
|||
# Updating path variable | |||
Write-Host "Updating path variable" | |||
$env:PATH = "$env:PATH;$nsisPath" | |||
|
|||
# Remove all bin and obj folders | |||
Write-Host "Cleaning the solution" | |||
Get-ChildItem $srcFolder -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } | |||
|
|||
# Perform a debug build | |||
& dotnet build $solutionFile /p:DebugType=Full | |||
|
|||
# Run unit tests | |||
$unitTestProjects = Get-ChildItem -Path $srcFolder -Filter *.Tests.csproj -Recurse | |||
Write-Host "Running unit tests" | |||
foreach($unitTest in $unitTestProjects) | |||
{ | |||
Write-Host $unitTest | |||
|
|||
& dotnet restore $unitTest.FullName | |||
Assert-Cmd-Ok | |||
|
|||
& dotnet test $unitTest.FullName | |||
Assert-Cmd-Ok | |||
} | |||
|
|||
# Release package build | |||
Write-Host "Building a release package" | |||
|
|||
& dotnet restore $mainProjectFile | |||
Assert-Cmd-Ok | |||
|
|||
# Reading version number | |||
Write-Host "Reading version from $mainProjectFile" | |||
[xml]$csproj = Get-Content $mainProjectFile | |||
$propertyGroupNode = $csproj.SelectSingleNode("/Project/PropertyGroup[1]") | |||
$version = [version]$propertyGroupNode.Version | |||
Write-Host "Found version $version" | |||
|
|||
. "$PSScriptRoot\build_windows.ps1" -srcFolder $srcFolder |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,30 @@ | |||
Param( | |||
[Parameter(Mandatory = $True)] | |||
[string]$srcFolder | |||
) | |||
|
|||
$ErrorActionPreference = 'Stop' | |||
|
|||
. "$PSScriptRoot\functions.ps1" | |||
|
|||
$nsiPath = Join-Path $PSScriptRoot "placeholder.nsi" | |||
$binDir = Join-Path $srcFolder "Placeholder\bin\release\netcoreapp2.0\win10-x64\publish" | |||
$installScriptsPath = Join-Path -Path $PSScriptRoot "installscripts\windows" | |||
|
|||
# Create Windows package | |||
Write-Host "Packing up for Windows" -ForegroundColor Green | |||
& dotnet publish $mainProjectFile --configuration=release --runtime=win10-x64 | |||
Assert-Cmd-Ok | |||
|
|||
# Moving install scripts for Windows | |||
Copy-Item (Join-Path $installScriptsPath "**") $binDir -Recurse | |||
|
|||
# Making installer | |||
$env:VersionMajor = $version.Major | |||
$env:VersionMinor = $version.Minor | |||
$env:VersionBuild = $version.Build | |||
$env:BuildOutputBinDirectory = $binDir | |||
$env:BuildOutputDirectory = $binDir | |||
Write-Host "Building installer $nsiPath" | |||
& makensis $nsiPath | |||
Assert-Cmd-Ok |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
function Assert-Cmd-Ok | |||
{ | |||
if($LASTEXITCODE -ne 0) | |||
{ | |||
Write-Error "Build not succeeded... See errors" | |||
Exit -1 | |||
} | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
# Make sure the install folder is added to the system path variable after install. | |||
Param( | |||
[Parameter(Mandatory=$True)] | |||
[string]$installFolder | |||
) | |||
|
|||
$environmentLocation = "hklm:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" | |||
$environment = Get-ItemProperty $environmentLocation | |||
$pathVar = $environment.Path | |||
if(!($pathVar -like "*$installFolder*")) | |||
{ | |||
$pathVar = "$pathVar;$installFolder" | |||
New-ItemProperty -Path $environmentLocation -Name "Path" -Value $pathVar -Force | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
# Make sure the install folder is removed from the path variable after deinstallation. | |||
Param( | |||
[Parameter(Mandatory=$True)] | |||
[string]$installFolder | |||
) | |||
|
|||
$environmentLocation = "hklm:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" | |||
$environment = Get-ItemProperty $environmentLocation | |||
$pathVar = $environment.Path | |||
$pathVar = $pathVar.Replace(";$installFolder", "") | |||
New-ItemProperty -Path $environmentLocation -Name "Path" -Value $pathVar -Force |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
SET APPVEYOR_BUILD_NUMBER=0 | |||
PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& %~dp0patch_versions.ps1" | |||
PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& %~dp0build.ps1" | |||
pause |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,32 @@ | |||
$ErrorActionPreference = 'Stop' | |||
|
|||
. "$PSScriptRoot\functions.ps1" | |||
|
|||
$rootFolder = Join-Path -Path $PSScriptRoot ".." | |||
$srcFolder = Join-Path -Path $rootFolder "src" | |||
$csprojPath = Join-Path -Path $srcFolder "Placeholder\Placeholder.csproj" | |||
|
|||
Write-Host "Reading file '$csprojPath'" | |||
[xml]$mainCsproj = Get-Content $csprojPath | |||
$propertyGroupNode = $mainCsproj.SelectSingleNode("/Project/PropertyGroup[1]") | |||
$version = [version]$propertyGroupNode.Version | |||
|
|||
Write-Host "Current version number: '$version'" | |||
|
|||
$versionString = "{0}.{1}.{2}.{3}" -f $version.Major, $version.Minor, $version.Build, $env:APPVEYOR_BUILD_NUMBER | |||
|
|||
Write-Host "New version number: '$versionString'" | |||
|
|||
$env:versionString = $versionString | |||
|
|||
$csprojFiles = Get-ChildItem -Path $srcFolder -Filter *.csproj -Recurse | |||
foreach($csprojFile in $csprojFiles) | |||
{ | |||
Write-Host "Parsing .csproj file $($csprojFile.FullName)" | |||
[xml]$csprojContents = Get-Content $csprojFile.FullName | |||
$propertyGroupNode = $csprojContents.SelectSingleNode("/Project/PropertyGroup[1]") | |||
$propertyGroupNode.Version = $versionString | |||
$propertyGroupNode.AssemblyVersion = $versionString | |||
$propertyGroupNode.FileVersion = $versionString | |||
$csprojContents.Save($csprojFile.FullName) | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,93 @@ | |||
!include "FileFunc.nsh" | |||
|
|||
!define APPNAME "Placeholder" | |||
!define COMPANYNAME "Ducode" | |||
!define DESCRIPTION "A very flexible cross platform HTTP stub application." | |||
!define VERSIONMAJOR "$%VersionMajor%" | |||
!define VERSIONMINOR "$%VersionMinor%" | |||
!define VERSIONBUILD "$%VersionBuild%" | |||
!define BINDIRECTORY "$%BuildOutputBinDirectory%" | |||
!define HELPURL "https://ducode.org" | |||
!define UPDATEURL "https://ducode.org" | |||
!define ABOUTURL "https://ducode.org" | |||
|
|||
RequestExecutionLevel admin | |||
|
|||
InstallDir "$PROGRAMFILES\${COMPANYNAME}\${APPNAME}" | |||
|
|||
LicenseData "..\LICENSE.txt" | |||
Name "${COMPANYNAME} - ${APPNAME}" | |||
outFile "$%BuildOutputDirectory%\placeholder_install.exe" | |||
|
|||
!include LogicLib.nsh | |||
|
|||
page license | |||
page directory | |||
Page instfiles | |||
|
|||
!macro VerifyUserIsAdmin | |||
UserInfo::GetAccountType | |||
pop $0 | |||
${If} $0 != "admin" | |||
messageBox mb_iconstop "Administrator rights required!" | |||
setErrorLevel 740 | |||
quit | |||
${EndIf} | |||
!macroend | |||
|
|||
function .onInit | |||
setShellVarContext all | |||
!insertmacro VerifyUserIsAdmin | |||
functionEnd | |||
|
|||
section "install" | |||
setOutPath $INSTDIR | |||
file /r "${BINDIRECTORY}\*" | |||
writeUninstaller "$INSTDIR\uninstall.exe" | |||
|
|||
createDirectory "$SMPROGRAMS\${COMPANYNAME}" | |||
createShortCut "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk" "$INSTDIR\Placeholder.exe" | |||
createShortCut "$SMPROGRAMS\${COMPANYNAME}\Uninstall ${APPNAME}.lnk" "$INSTDIR\uninstall.exe" | |||
|
|||
# Calculate installed size | |||
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 | |||
IntFmt $0 "0x%08X" $0 | |||
|
|||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayName" "${COMPANYNAME} - ${APPNAME} - ${DESCRIPTION}" | |||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" | |||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" | |||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" "$\"$INSTDIR$\"" | |||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayIcon" "$INSTDIR\Placeholder.exe" | |||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "${COMPANYNAME}" | |||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "HelpLink" "${HELPURL}" | |||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLUpdateInfo" "${UPDATEURL}" | |||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLInfoAbout" "${ABOUTURL}" | |||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayVersion" "${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}" | |||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMajor" ${VERSIONMAJOR} | |||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMinor" ${VERSIONMINOR} | |||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoModify" 1 | |||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoRepair" 1 | |||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "EstimatedSize" $0 | |||
|
|||
ExecWait 'powershell.exe -NoProfile -ExecutionPolicy Unrestricted -Command "& \"$INSTDIR\add_path_var.ps1\"" -installFolder \"$INSTDIR\"' | |||
sectionEnd | |||
|
|||
function un.onInit | |||
SetShellVarContext all | |||
|
|||
MessageBox MB_YESNO "Permanantly remove ${APPNAME}?" /SD IDYES IDYES next IDNO abort | |||
abort: | |||
Abort | |||
next: | |||
!insertmacro VerifyUserIsAdmin | |||
functionEnd | |||
|
|||
section "uninstall" | |||
ExecWait 'powershell.exe -NoProfile -ExecutionPolicy Unrestricted -Command "& \"$INSTDIR\remove_path_var.ps1\"" -installFolder \"$INSTDIR\"' | |||
|
|||
rmDir /r "$SMPROGRAMS\${COMPANYNAME}" | |||
|
|||
rmDir /r $INSTDIR | |||
|
|||
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" | |||
sectionEnd |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,7 +1,8 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|||
<PropertyGroup> | <PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | <TargetFramework>netstandard2.0</TargetFramework> | ||
<Version>1.0.0.0</Version> | |||
<AssemblyVersion>1.0.0.0</AssemblyVersion> | |||
<FileVersion>1.0.0.0</FileVersion> | |||
</PropertyGroup> | </PropertyGroup> | ||
|
</Project> | ||
</Project> |
12 changes: 4 additions & 8 deletions
12
src/Placeholder.Implementation.Tests/Placeholder.Implementation.Tests.csproj
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,30 +1,26 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|||
<PropertyGroup> | <PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | <TargetFramework>netcoreapp2.0</TargetFramework> | ||
|
|||
<IsPackable>false</IsPackable> | <IsPackable>false</IsPackable> | ||
<Version>1.0.0.0</Version> | |||
<AssemblyVersion>1.0.0.0</AssemblyVersion> | |||
<FileVersion>1.0.0.0</FileVersion> | |||
</PropertyGroup> | </PropertyGroup> | ||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | <TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<WarningsAsErrors /> | <WarningsAsErrors /> | ||
</PropertyGroup> | </PropertyGroup> | ||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | <TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<WarningsAsErrors /> | <WarningsAsErrors /> | ||
</PropertyGroup> | </PropertyGroup> | ||
|
|||
<ItemGroup> | <ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" /> | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" /> | ||
<PackageReference Include="Moq" Version="4.8.2" /> | <PackageReference Include="Moq" Version="4.8.2" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="1.2.1" /> | <PackageReference Include="MSTest.TestAdapter" Version="1.2.1" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="1.2.1" /> | <PackageReference Include="MSTest.TestFramework" Version="1.2.1" /> | ||
</ItemGroup> | </ItemGroup> | ||
|
|||
<ItemGroup> | <ItemGroup> | ||
<ProjectReference Include="..\Placeholder.Implementation\Placeholder.Implementation.csproj" /> | <ProjectReference Include="..\Placeholder.Implementation\Placeholder.Implementation.csproj" /> | ||
</ItemGroup> | </ItemGroup> | ||
|
</Project> | ||
</Project> |
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
Oops, something went wrong.