Commit 19891e1f authored by Benedikt Heinrichs's avatar Benedikt Heinrichs

Initial commit

parent fc17556b
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
Resharper
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
#cake
tools/
dist/
\ No newline at end of file
stages:
- build
- test
- docs
- update-assembly-info
- build-release
- semantic-release
- release
build:
before_script:
- PowerShell .\build.ps1 -Target Clean
- PowerShell .\build.ps1 -Target Restore-NuGet-Packages
stage: build
script:
- PowerShell .\build.ps1 -Target Build
except:
variables:
- $GITLAB_USER_ID == $GIT_BOT_USER_ID
test:
stage: test
script:
- PowerShell .\build.ps1 -Target Resharper
- PowerShell .\build.ps1 -Target Run-Unit-Tests
variables:
GIT_STRATEGY: none
dependencies:
- build
artifacts:
reports:
junit: TestResult.xml
except:
variables:
- $GITLAB_USER_ID == $GIT_BOT_USER_ID
update-assembly-info:
stage: update-assembly-info
script:
- PowerShell .\build.ps1 -Target Update-Assembly-Info
variables:
GIT_STRATEGY: none
dependencies:
- test
only:
- master
except:
variables:
- $GITLAB_USER_ID == $GIT_BOT_USER_ID
build-release:
before_script:
- PowerShell .\build.ps1 -Target Clean
- PowerShell .\build.ps1 -Target Restore-NuGet-Packages
stage: build-release
script:
- PowerShell .\build.ps1 -Target Build-Release
variables:
GIT_STRATEGY: none
dependencies:
- update-assembly-info
only:
- master
except:
variables:
- $GITLAB_USER_ID == $GIT_BOT_USER_ID
docs:
stage: docs
script:
- .\publishDocs.ps1 $GITLAB_TOKEN
variables:
GIT_STRATEGY: none
dependencies:
- test
only:
- master
except:
variables:
- $GITLAB_USER_ID == $GIT_BOT_USER_ID
semantic-release:
stage: semantic-release
script:
- PowerShell .\build.ps1 -Target Semantic-Release
variables:
GIT_STRATEGY: none
dependencies:
- test
only:
- master
except:
variables:
- $GITLAB_USER_ID == $GIT_BOT_USER_ID
release:
stage: release
script:
- PowerShell .\build.ps1 -Target Build-Release
variables:
GIT_STRATEGY: none
artifacts:
paths:
- dist
only:
- tags
{
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "eslint"
}],
["@semantic-release/release-notes-generator", {
"preset": "eslint",
}],
["@semantic-release/gitlab", {
"preset": "eslint",
"gitlabUrl": "https://git.rwth-aachen.de"
}],
["@semantic-release/exec", {
"prepareCmd" : "echo ${nextRelease.version}",
"publishCmd" : "echo test"
}],
["@semantic-release/git", {
"preset": "eslint",
"assets": "src/**/Properties/AssemblyInfo.cs",
"message": "Chore: ${nextRelease.version}\n\n${nextRelease.notes}"
}]
]
}
\ No newline at end of file
MIT License
Copyright (c) 2019 RWTH Aachen University
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.
\ No newline at end of file
#tool nuget:?package=NUnit.ConsoleRunner&version=3.9.0
#tool nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2018.3.4
#addin nuget:https://api.nuget.org/v3/index.json?package=Cake.Npx&version=1.3.0
#addin nuget:https://api.nuget.org/v3/index.json?package=Cake.Issues&version=0.6.2
#addin nuget:https://api.nuget.org/v3/index.json?package=Cake.Issues.InspectCode&version=0.6.1
#addin nuget:https://api.nuget.org/v3/index.json?package=Cake.FileHelpers&version=3.1.0
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Define directories.
string projectName;
string projectPath;
DirectoryPath buildDir;
FilePath solutionFile;
// Error rules for resharper
// Example: {"InconsistentNaming", "RedundantUsingDirective"};
string [] resharperErrorRules = {};
Action<NpxSettings> requiredSemanticVersionPackages = settings => settings
.AddPackage("semantic-release")
.AddPackage("@semantic-release/commit-analyzer")
.AddPackage("@semantic-release/release-notes-generator")
.AddPackage("@semantic-release/gitlab")
.AddPackage("@semantic-release/git")
.AddPackage("@semantic-release/exec")
.AddPackage("conventional-changelog-eslint");
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Get-Project-Name")
.Does(() =>
{
var solutions = GetFiles("./**/*.sln");
projectName = solutions.First().GetFilenameWithoutExtension().ToString();
Information("Project Name: {0}", projectName);
solutionFile = solutions.First().ToString();
Information("Solution File: {0}", solutionFile.ToString());
projectPath = Context.Environment.WorkingDirectory.ToString().ToString() + "/src";
Information("Project Directory: {0}", projectPath);
buildDir = Directory(projectPath + "/" + projectName + "/bin") + Directory(configuration);
Information("Build Directory: {0}", buildDir.ToString());
});
Task("Clean")
.IsDependentOn("Get-Project-Name")
.Does(() =>
{
CleanDirectory(buildDir);
CleanDirectory("./dist");
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Get-Project-Name")
.Does(() =>
{
NuGetRestore(solutionFile);
});
Task("Resharper")
.IsDependentOn("Get-Project-Name")
.Does(() =>
{
FilePath dupLog = Context.Environment.WorkingDirectory + "/Resharper/dupfinder.xml";
FilePath inspectLog = Context.Environment.WorkingDirectory + "/Resharper/inspectcode.xml";
DupFinder(solutionFile, new DupFinderSettings() {
OutputFile = dupLog.ToString()
});
Information("DupFinder Log:{0}{1}", Environment.NewLine, FileReadText(dupLog));
InspectCode(solutionFile, new InspectCodeSettings() {
OutputFile = inspectLog.ToString()
});
var issues = ReadIssues(
InspectCodeIssuesFromFilePath(inspectLog.ToString()),
Context.Environment.WorkingDirectory);
Information("{0} issues are found.", issues.Count());
Information("InspectCode Log:{0}{1}", Environment.NewLine, FileReadText(inspectLog));
var errorIssues = issues.Where(issue => resharperErrorRules.Any(issue.Rule.Contains)).ToList();
if(errorIssues.Any())
{
var errorMessage = errorIssues.Aggregate(new StringBuilder(), (stringBuilder, issue) => stringBuilder.AppendFormat("FileName: {0} Line: {1} Message: {2}{3}", issue.AffectedFileRelativePath, issue.Line, issue.Message, Environment.NewLine));
throw new CakeException($"{errorIssues.Count} errors detected: {Environment.NewLine}{errorMessage}.");
}
});
Task("Update-Assembly-Info")
.IsDependentOn("Get-Project-Name")
.Does(() =>
{
Information("Running semantic-release in dry run mode to extract next semantic version number");
string[] semanticReleaseOutput;
Npx("semantic-release", "--dry-run", requiredSemanticVersionPackages, out semanticReleaseOutput);
Information(string.Join(Environment.NewLine, semanticReleaseOutput));
var nextSemanticVersionNumber = ExtractNextSemanticVersionNumber(semanticReleaseOutput);
if (nextSemanticVersionNumber == null) {
Warning("There are no relevant changes. AssemblyInfo won't be updated!");
} else {
Information("Next semantic version number is {0}", nextSemanticVersionNumber);
var assemblyVersion = $"{nextSemanticVersionNumber}.0";
CreateAssemblyInfo(projectPath + "/" + projectName + "/Properties/AssemblyInfo.cs", new AssemblyInfoSettings{
Product = projectName,
Title = projectName,
Company = "RWTH Aachen University IT Center",
Version = assemblyVersion,
FileVersion = assemblyVersion,
InformationalVersion = assemblyVersion,
Copyright = "RWTH Aachen University IT Center " + DateTime.Now.Year
});
}
});
Task("Build-Release")
.IsDependentOn("Get-Project-Name")
.Does(() =>
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild(solutionFile, settings =>
{
settings.SetConfiguration(configuration);
settings.WithProperty("DebugSymbols", "false");
settings.WithProperty("DebugType", "None");
});
}
else
{
// Use XBuild
XBuild(solutionFile, settings =>
{
settings.SetConfiguration(configuration);
settings.WithProperty("DebugSymbols", "false");
settings.WithProperty("DebugType", "None");
});
}
CopyDirectory(buildDir, "./dist");
});
Task("Build")
.IsDependentOn("Get-Project-Name")
.Does(() =>
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild(solutionFile, settings =>
{
settings.SetConfiguration(configuration);
settings.WithProperty("RunCodeAnalysis", "true");
});
}
else
{
// Use XBuild
XBuild(solutionFile, settings =>
{
settings.SetConfiguration(configuration);
settings.WithProperty("RunCodeAnalysis", "true");
});
}
});
Task("Run-Unit-Tests")
.Does(() =>
{
NUnit3("./src/**/bin/" + configuration + "/*.Tests.dll", new NUnit3Settings {
// generate the xml file
NoResults = false,
Results = new NUnit3Result[]{new NUnit3Result(){
FileName = Context.Environment.WorkingDirectory + "/TestResult.xml",
Transform = Context.Environment.WorkingDirectory + "/nunit3-junit.xslt"
}}
});
});
Task("Semantic-Release")
.Does(() =>
{
Npx("semantic-release", requiredSemanticVersionPackages);
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("Restore-NuGet-Packages")
.IsDependentOn("Resharper")
.IsDependentOn("Build")
.IsDependentOn("Run-Unit-Tests");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);
///////////////////////////////////////////////////////////////////////////////
// Helpers
///////////////////////////////////////////////////////////////////////////////
string ExtractNextSemanticVersionNumber(string[] semanticReleaseOutput)
{
var extractRegEx = new System.Text.RegularExpressions.Regex("^.+next release version is (?<SemanticVersionNumber>.*)$");
return semanticReleaseOutput
.Select(line => extractRegEx.Match(line).Groups["SemanticVersionNumber"].Value)
.Where(line => !string.IsNullOrWhiteSpace(line))
.SingleOrDefault();
}
\ No newline at end of file
#The MIT License (MIT)
#
#Copyright (c) 2014 - 2016 Patrik Svensson, Mattias Karlsson, Gary Ewan Park and contributors
#
#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