This commit is contained in:
Wiesław Šoltés 2018-12-08 15:32:51 +01:00
Родитель 20a025334e
Коммит 567f2bdebf
9 изменённых файлов: 339 добавлений и 45 удалений

0
.nuke Normal file
Просмотреть файл

Просмотреть файл

@ -1,10 +1,45 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2026
# Visual Studio Version 16
VisualStudioVersion = 16.0.28315.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MicroStationTagExplorer", "src\MicroStationTagExplorer\MicroStationTagExplorer.csproj", "{59F5B5F5-2569-4263-9E94-D53DA097FCAD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{9902A49C-859A-4D9A-9AF6-FB339F6111F6}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.nuke = .nuke
build.ps1 = build.ps1
build.sh = build.sh
global.json = global.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{65DBC338-AE3B-4D7C-ACF6-27396E36399A}"
ProjectSection(SolutionItems) = preProject
LICENSE.TXT = LICENSE.TXT
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B9D9DF55-9942-4B6C-8888-04A1A9796F28}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "git", "git", "{F28555CF-1400-475F-961A-2E7526007721}"
ProjectSection(SolutionItems) = preProject
.gitattributes = .gitattributes
.gitignore = .gitignore
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nuget", "nuget", "{4FAF7F3F-9388-4816-9F5E-9DCC36C1FE9B}"
ProjectSection(SolutionItems) = preProject
NuGet.Config = NuGet.Config
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "props", "props", "{4040A339-594D-435E-BEEB-2E5E435BD5E9}"
ProjectSection(SolutionItems) = preProject
build\Base.props = build\Base.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\build\_build.csproj", "{07E23276-AB9E-4245-8869-A2B681AD602B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -15,10 +50,21 @@ Global
{59F5B5F5-2569-4263-9E94-D53DA097FCAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59F5B5F5-2569-4263-9E94-D53DA097FCAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59F5B5F5-2569-4263-9E94-D53DA097FCAD}.Release|Any CPU.Build.0 = Release|Any CPU
{07E23276-AB9E-4245-8869-A2B681AD602B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07E23276-AB9E-4245-8869-A2B681AD602B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07E23276-AB9E-4245-8869-A2B681AD602B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07E23276-AB9E-4245-8869-A2B681AD602B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{59F5B5F5-2569-4263-9E94-D53DA097FCAD} = {B9D9DF55-9942-4B6C-8888-04A1A9796F28}
{F28555CF-1400-475F-961A-2E7526007721} = {9902A49C-859A-4D9A-9AF6-FB339F6111F6}
{4FAF7F3F-9388-4816-9F5E-9DCC36C1FE9B} = {9902A49C-859A-4D9A-9AF6-FB339F6111F6}
{4040A339-594D-435E-BEEB-2E5E435BD5E9} = {9902A49C-859A-4D9A-9AF6-FB339F6111F6}
{07E23276-AB9E-4245-8869-A2B681AD602B} = {9902A49C-859A-4D9A-9AF6-FB339F6111F6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4E264536-B566-4146-96C3-B6A810B59EB8}
EndGlobalSection

Просмотреть файл

@ -1,20 +0,0 @@
version: 1.0.0-build{build}
image: Visual Studio 2017
configuration: Release
platform: Any CPU
assembly_info:
patch: true
file: '**\AssemblyInfo.*'
assembly_version: '{version}'
assembly_file_version: '{version}'
assembly_informational_version: '{version}'
build:
project: MicroStationTagExplorer.sln
verbosity: minimal
test: off
artifacts:
- path: src\MicroStationTagExplorer
- path: interop\Excel 2016
- path: interop\View V8i
- path: src\MicroStationTagExplorer\bin\AnyCPU\Release\MicroStationTagExplorer.exe
deploy: off

Просмотреть файл

@ -1,23 +0,0 @@
jobs:
- job: Windows
pool:
vmImage: 'vs2017-win2016'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: DotNetCoreInstaller@0
inputs:
version: '2.1.500'
- task: NuGetToolInstaller@0
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
feedsToUse: 'config'
nugetConfigPath: 'NuGet.Config'
- task: VSBuild@1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'

69
build.ps1 Normal file
Просмотреть файл

@ -0,0 +1,69 @@
[CmdletBinding()]
Param(
#[switch]$CustomParam,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$BuildArguments
)
Write-Output "Windows PowerShell $($Host.Version)"
Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { exit 1 }
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
###########################################################################
# CONFIGURATION
###########################################################################
$BuildProjectFile = "$PSScriptRoot\build\build\_build.csproj"
$TempDirectory = "$PSScriptRoot\\.tmp"
$DotNetGlobalFile = "$PSScriptRoot\\global.json"
$DotNetInstallUrl = "https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1"
$DotNetChannel = "Current"
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
$env:NUGET_XMLDOC_MODE = "skip"
###########################################################################
# EXECUTION
###########################################################################
function ExecSafe([scriptblock] $cmd) {
& $cmd
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
# If global.json exists, load expected version
if (Test-Path $DotNetGlobalFile) {
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
$DotNetVersion = $DotNetGlobal.sdk.version
}
}
# If dotnet is installed locally, and expected version is not set or installation matches the expected version
if ((Get-Command "dotnet" -ErrorAction SilentlyContinue) -ne $null -and `
(!(Test-Path variable:DotNetVersion) -or $(& dotnet --version) -eq $DotNetVersion)) {
$env:DOTNET_EXE = (Get-Command "dotnet").Path
}
else {
$DotNetDirectory = "$TempDirectory\dotnet-win"
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
# Download install script
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
md -force $TempDirectory > $null
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
# Install by channel or version
if (!(Test-Path variable:DotNetVersion)) {
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
} else {
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
}
}
Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile -- $BuildArguments }

72
build.sh Normal file
Просмотреть файл

@ -0,0 +1,72 @@
#!/usr/bin/env bash
echo $(bash --version 2>&1 | head -n 1)
#CUSTOMPARAM=0
BUILD_ARGUMENTS=()
for i in "$@"; do
case $(echo $1 | awk '{print tolower($0)}') in
# -custom-param) CUSTOMPARAM=1;;
*) BUILD_ARGUMENTS+=("$1") ;;
esac
shift
done
set -eo pipefail
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
###########################################################################
# CONFIGURATION
###########################################################################
BUILD_PROJECT_FILE="$SCRIPT_DIR/build/build/_build.csproj"
TEMP_DIRECTORY="$SCRIPT_DIR//.tmp"
DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
DOTNET_INSTALL_URL="https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh"
DOTNET_CHANNEL="Current"
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export NUGET_XMLDOC_MODE="skip"
###########################################################################
# EXECUTION
###########################################################################
function FirstJsonValue {
perl -nle 'print $1 if m{"'$1'": "([^"\-]+)",?}' <<< ${@:2}
}
# If global.json exists, load expected version
if [ -f "$DOTNET_GLOBAL_FILE" ]; then
DOTNET_VERSION=$(FirstJsonValue "version" $(cat "$DOTNET_GLOBAL_FILE"))
if [ "$DOTNET_VERSION" == "" ]; then
unset DOTNET_VERSION
fi
fi
# If dotnet is installed locally, and expected version is not set or installation matches the expected version
if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version) == "$DOTNET_VERSION") ]]; then
export DOTNET_EXE="$(command -v dotnet)"
else
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
# Download install script
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
mkdir -p "$TEMP_DIRECTORY"
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
chmod +x "$DOTNET_INSTALL_FILE"
# Install by channel or version
if [ -z ${DOTNET_VERSION+x} ]; then
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
else
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
fi
fi
echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)"
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" -- ${BUILD_ARGUMENTS[@]}

11
build/Base.props Normal file
Просмотреть файл

@ -0,0 +1,11 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<Authors>Wiesław Šoltés</Authors>
<Company>Wiesław Šoltés</Company>
<Copyright>Copyright © Wiesław Šoltés 2018</Copyright>
<PackageLicenseUrl>https://github.com/wieslawsoltes/MicroStationTagExplorer/blob/master/LICENSE.TXT</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/wieslawsoltes/MicroStationTagExplorer</PackageProjectUrl>
</PropertyGroup>
</Project>

117
build/build/Build.cs Normal file
Просмотреть файл

@ -0,0 +1,117 @@
using System;
using System.Linq;
using Nuke.Common;
using Nuke.Common.Git;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tools.DotNet;
using static Nuke.Common.EnvironmentInfo;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
class Build : NukeBuild
{
public static int Main() => Execute<Build>(x => x.Compile);
[Solution("MicroStationTagExplorer.sln")]
readonly Solution Solution;
[GitRepository]
readonly GitRepository GitRepository;
[Parameter("configuration")]
public string Configuration { get; set; }
[Parameter("version-suffix")]
public string VersionSuffix { get; set; }
[Parameter("publish-framework")]
public string PublishFramework { get; set; }
[Parameter("publish-runtime")]
public string PublishRuntime { get; set; }
[Parameter("publish-project")]
public string PublishProject { get; set; }
AbsolutePath SourceDirectory => RootDirectory / "src";
AbsolutePath TestsDirectory => RootDirectory / "tests";
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
protected override void OnBuildInitialized()
{
Configuration = Configuration ?? "Release";
VersionSuffix = VersionSuffix ?? "";
}
Target Clean => _ => _
.Executes(() =>
{
DeleteDirectories(GlobDirectories(SourceDirectory, "**/bin", "**/obj"));
DeleteDirectories(GlobDirectories(TestsDirectory, "**/bin", "**/obj"));
EnsureCleanDirectory(ArtifactsDirectory);
});
Target Restore => _ => _
.DependsOn(Clean)
.Executes(() =>
{
DotNetRestore(s => s
.SetProjectFile(Solution));
});
Target Compile => _ => _
.DependsOn(Restore)
.Executes(() =>
{
DotNetBuild(s => s
.SetProjectFile(Solution)
.SetConfiguration(Configuration)
.SetVersionSuffix(VersionSuffix)
.EnableNoRestore());
});
Target Test => _ => _
.DependsOn(Compile)
.Executes(() =>
{
DotNetTest(s => s
.SetProjectFile(Solution)
.SetConfiguration(Configuration)
.SetLogger("trx")
.SetResultsDirectory(ArtifactsDirectory / "TestResults")
.EnableNoBuild()
.EnableNoRestore());
});
Target Pack => _ => _
.DependsOn(Test)
.Executes(() =>
{
DotNetPack(s => s
.SetProject(Solution)
.SetConfiguration(Configuration)
.SetVersionSuffix(VersionSuffix)
.SetOutputDirectory(ArtifactsDirectory / "NuGet")
.EnableNoBuild()
.EnableNoRestore());
});
Target Publish => _ => _
.DependsOn(Test)
.Requires(() => PublishRuntime)
.Requires(() => PublishFramework)
.Requires(() => PublishProject)
.Executes(() =>
{
DotNetPublish(s => s
.SetProject(Solution.GetProject(PublishProject))
.SetConfiguration(Configuration)
.SetVersionSuffix(VersionSuffix)
.SetFramework(PublishFramework)
.SetRuntime(PublishRuntime)
.SetOutput(ArtifactsDirectory / "Publish" / PublishProject + "-" + PublishRuntime));
});
}

22
build/build/_build.csproj Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<RootNamespace></RootNamespace>
<IsPackable>False</IsPackable>
<NoWarn>CS0649;CS0169</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nuke.Common" Version="0.12.3" />
</ItemGroup>
<ItemGroup>
<NukeMetadata Include="**\*.json" Exclude="bin\**;obj\**" />
<NukeExternalFiles Include="**\*.*.ext" Exclude="bin\**;obj\**" />
<None Remove="*.ref;*.txt" />
</ItemGroup>
</Project>