diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..7c2965eda294e35b644059bf493b44aa290aebb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,266 @@ +## 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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..a60ae9cac3363615b4f1ae284ba69ccae900c97e --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,108 @@ + + +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 diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000000000000000000000000000000000000..576a3f725c1310a69365c11aae327a9f61e5dc47 --- /dev/null +++ b/.releaserc @@ -0,0 +1,23 @@ +{ + "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 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..1cacbda86167c5f5629e9d3f8605295ad009460f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +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 diff --git a/build.cake b/build.cake new file mode 100644 index 0000000000000000000000000000000000000000..9167f136cd91b4c3805451f5c14b6009130cae7c --- /dev/null +++ b/build.cake @@ -0,0 +1,241 @@ +#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 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 (?.*)$"); + + return semanticReleaseOutput + .Select(line => extractRegEx.Match(line).Groups["SemanticVersionNumber"].Value) + .Where(line => !string.IsNullOrWhiteSpace(line)) + .SingleOrDefault(); +} \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..f83382e8e4092ba6cf32a47f9dfa4e211c878430 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,255 @@ +#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 +#CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +########################################################################## +# This is the Cake bootstrapper script for PowerShell. +# This file was downloaded from https://github.com/cake-build/resources +# Feel free to change this file to fit your needs. +########################################################################## + +<# + +.SYNOPSIS +This is a Powershell script to bootstrap a Cake build. + +.DESCRIPTION +This Powershell script will download NuGet if missing, restore NuGet tools (including Cake) +and execute your Cake build script with the parameters you provide. + +.PARAMETER Script +The build script to execute. +.PARAMETER Target +The build script target to run. +.PARAMETER Configuration +The build configuration to use. +.PARAMETER Verbosity +Specifies the amount of information to be displayed. +.PARAMETER ShowDescription +Shows description about tasks. +.PARAMETER DryRun +Performs a dry run. +.PARAMETER Experimental +Uses the nightly builds of the Roslyn script engine. +.PARAMETER Mono +Uses the Mono Compiler rather than the Roslyn script engine. +.PARAMETER SkipToolPackageRestore +Skips restoring of packages. +.PARAMETER ScriptArgs +Remaining arguments are added here. + +.LINK +https://cakebuild.net + +#> + +[CmdletBinding()] +Param( + [string]$Script = "build.cake", + [string]$Target, + [string]$Configuration, + [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] + [string]$Verbosity, + [switch]$ShowDescription, + [Alias("WhatIf", "Noop")] + [switch]$DryRun, + [switch]$Experimental, + [switch]$Mono, + [switch]$SkipToolPackageRestore, + [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] + [string[]]$ScriptArgs +) + +[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null +function MD5HashFile([string] $filePath) +{ + if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) + { + return $null + } + + [System.IO.Stream] $file = $null; + [System.Security.Cryptography.MD5] $md5 = $null; + try + { + $md5 = [System.Security.Cryptography.MD5]::Create() + $file = [System.IO.File]::OpenRead($filePath) + return [System.BitConverter]::ToString($md5.ComputeHash($file)) + } + finally + { + if ($file -ne $null) + { + $file.Dispose() + } + } +} + +function GetProxyEnabledWebClient +{ + $wc = New-Object System.Net.WebClient + $proxy = [System.Net.WebRequest]::GetSystemWebProxy() + $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials + $wc.Proxy = $proxy + return $wc +} + +Write-Host "Preparing to run build script..." + +if(!$PSScriptRoot){ + $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent +} + +$TOOLS_DIR = Join-Path $PSScriptRoot "tools" +$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins" +$MODULES_DIR = Join-Path $TOOLS_DIR "Modules" +$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" +$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" +$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" +$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" +$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" +$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config" +$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config" + +# Make sure tools folder exists +if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { + Write-Verbose -Message "Creating tools directory..." + New-Item -Path $TOOLS_DIR -Type directory | out-null +} + +# Make sure that packages.config exist. +if (!(Test-Path $PACKAGES_CONFIG)) { + Write-Verbose -Message "Downloading packages.config..." + try { + $wc = GetProxyEnabledWebClient + $wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch { + Throw "Could not download packages.config." + } +} + +# Try find NuGet.exe in path if not exists +if (!(Test-Path $NUGET_EXE)) { + Write-Verbose -Message "Trying to find nuget.exe in PATH..." + $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) } + $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 + if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { + Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." + $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName + } +} + +# Try download NuGet.exe if not exists +if (!(Test-Path $NUGET_EXE)) { + Write-Verbose -Message "Downloading NuGet.exe..." + try { + $wc = GetProxyEnabledWebClient + $wc.DownloadFile($NUGET_URL, $NUGET_EXE) + } catch { + Throw "Could not download NuGet.exe." + } +} + +# Save nuget.exe path to environment to be available to child processed +$ENV:NUGET_EXE = $NUGET_EXE + +# Restore tools from NuGet? +if(-Not $SkipToolPackageRestore.IsPresent) { + Push-Location + Set-Location $TOOLS_DIR + + # Check for changes in packages.config and remove installed tools if true. + [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) + if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or + ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { + Write-Verbose -Message "Missing or changed package.config hash..." + Remove-Item * -Recurse -Exclude packages.config,nuget.exe + } + + Write-Verbose -Message "Restoring tools from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occurred while restoring NuGet tools." + } + else + { + $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" + } + Write-Verbose -Message ($NuGetOutput | out-string) + + Pop-Location +} + +# Restore addins from NuGet +if (Test-Path $ADDINS_PACKAGES_CONFIG) { + Push-Location + Set-Location $ADDINS_DIR + + Write-Verbose -Message "Restoring addins from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occurred while restoring NuGet addins." + } + + Write-Verbose -Message ($NuGetOutput | out-string) + + Pop-Location +} + +# Restore modules from NuGet +if (Test-Path $MODULES_PACKAGES_CONFIG) { + Push-Location + Set-Location $MODULES_DIR + + Write-Verbose -Message "Restoring modules from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occurred while restoring NuGet modules." + } + + Write-Verbose -Message ($NuGetOutput | out-string) + + Pop-Location +} + +# Make sure that Cake has been installed. +if (!(Test-Path $CAKE_EXE)) { + Throw "Could not find Cake.exe at $CAKE_EXE" +} + + + +# Build Cake arguments +$cakeArguments = @("$Script"); +if ($Target) { $cakeArguments += "-target=$Target" } +if ($Configuration) { $cakeArguments += "-configuration=$Configuration" } +if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" } +if ($ShowDescription) { $cakeArguments += "-showdescription" } +if ($DryRun) { $cakeArguments += "-dryrun" } +if ($Experimental) { $cakeArguments += "-experimental" } +if ($Mono) { $cakeArguments += "-mono" } +$cakeArguments += $ScriptArgs + +# Start Cake +Write-Host "Running build script..." +&$CAKE_EXE $cakeArguments +exit $LASTEXITCODE diff --git a/build.sh b/build.sh new file mode 100644 index 0000000000000000000000000000000000000000..d088917ed78538ff57cf654cf71aad6bf045d655 --- /dev/null +++ b/build.sh @@ -0,0 +1,122 @@ +#!/usr/bin/env bash + +#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 +#CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +########################################################################## +# This is the Cake bootstrapper script for Linux and OS X. +# This file was downloaded from https://github.com/cake-build/resources +# Feel free to change this file to fit your needs. +########################################################################## + +# Define directories. +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +TOOLS_DIR=$SCRIPT_DIR/tools +NUGET_EXE=$TOOLS_DIR/nuget.exe +CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe +PACKAGES_CONFIG=$TOOLS_DIR/packages.config +PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum + +# Define md5sum or md5 depending on Linux/OSX +MD5_EXE= +if [[ "$(uname -s)" == "Darwin" ]]; then + MD5_EXE="md5 -r" +else + MD5_EXE="md5sum" +fi + +# Define default arguments. +SCRIPT="build.cake" +TARGET="Default" +CONFIGURATION="Release" +VERBOSITY="verbose" +DRYRUN= +SHOW_VERSION=false +SCRIPT_ARGUMENTS=() + +# Parse arguments. +for i in "$@"; do + case $1 in + -s|--script) SCRIPT="$2"; shift ;; + -t|--target) TARGET="$2"; shift ;; + -c|--configuration) CONFIGURATION="$2"; shift ;; + -v|--verbosity) VERBOSITY="$2"; shift ;; + -d|--dryrun) DRYRUN="-dryrun" ;; + --version) SHOW_VERSION=true ;; + --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;; + *) SCRIPT_ARGUMENTS+=("$1") ;; + esac + shift +done + +# Make sure the tools folder exist. +if [ ! -d "$TOOLS_DIR" ]; then + mkdir "$TOOLS_DIR" +fi + +# Make sure that packages.config exist. +if [ ! -f "$TOOLS_DIR/packages.config" ]; then + echo "Downloading packages.config..." + curl -Lsfo "$TOOLS_DIR/packages.config" https://cakebuild.net/download/bootstrapper/packages + if [ $? -ne 0 ]; then + echo "An error occurred while downloading packages.config." + exit 1 + fi +fi + +# Download NuGet if it does not exist. +if [ ! -f "$NUGET_EXE" ]; then + echo "Downloading NuGet..." + curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe + if [ $? -ne 0 ]; then + echo "An error occurred while downloading nuget.exe." + exit 1 + fi +fi + +# Restore tools from NuGet. +pushd "$TOOLS_DIR" >/dev/null +if [ ! -f $PACKAGES_CONFIG_MD5 ] || [ "$( cat $PACKAGES_CONFIG_MD5 | sed 's/\r$//' )" != "$( $MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' )" ]; then + find . -type d ! -name . | xargs rm -rf +fi + +mono "$NUGET_EXE" install -ExcludeVersion +if [ $? -ne 0 ]; then + echo "Could not restore NuGet packages." + exit 1 +fi + +$MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' >| $PACKAGES_CONFIG_MD5 + +popd >/dev/null + +# Make sure that Cake has been installed. +if [ ! -f "$CAKE_EXE" ]; then + echo "Could not find Cake.exe at '$CAKE_EXE'." + exit 1 +fi + +# Start Cake +if $SHOW_VERSION; then + exec mono "$CAKE_EXE" -version +else + exec mono "$CAKE_EXE" $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" +fi \ No newline at end of file diff --git a/docs/home.md b/docs/home.md new file mode 100644 index 0000000000000000000000000000000000000000..45bba1687864c90cc2083b40c1a6cc95e9c96ff6 --- /dev/null +++ b/docs/home.md @@ -0,0 +1,20 @@ +# Project Api + +This Api represents the connection to the projects. + +## NuGet packages + +To use Kestrel you need to add the following NuGet packages: + +* ```Microsoft.AspNetCore.Server.Kestrel``` +* ```Microsoft.AspNetCore.Mvc``` +* ```Microsoft.AspNetCore``` + +## Https usage + +Generate a developer certificate: ```dotnet dev-certs https``` +and then trust the generated certificate ```dotnet dev-certs https --trust``` + +## Testing the new server + +The server ist now available under: https://localhost:5001/ (port may be diffrent!) \ No newline at end of file diff --git a/nunit3-junit.xslt b/nunit3-junit.xslt new file mode 100644 index 0000000000000000000000000000000000000000..bf69bdb1d2cd6fc2fdbeb915b4eb6732f720848e --- /dev/null +++ b/nunit3-junit.xslt @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/projectapi.nomad b/projectapi.nomad new file mode 100644 index 0000000000000000000000000000000000000000..eead5d24d5cf175fdeafd88a613cc344ee046ff9 --- /dev/null +++ b/projectapi.nomad @@ -0,0 +1,14 @@ +job "projectapi" { + datacenters = ["dc1"] + + group "projectapi" { + task "projectapi" { + driver = "raw_exec" + + config { + command = "C:/Programs/api/project/Project.exe" + args = [] + } + } + } +} \ No newline at end of file diff --git a/publishDocs.ps1 b/publishDocs.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..f49b3b93e477ca9d57f7b1163b2bcf246f86d35d --- /dev/null +++ b/publishDocs.ps1 @@ -0,0 +1,19 @@ +param( + $token +) + +$remoteUrl = git config --get remote.origin.url +$remoteUrl = $remoteUrl.replace("git@", "") +$remoteUrl = $remoteUrl -replace "https(.*?)@","" +$remoteUrl = $remoteUrl.replace(":", "/") +$remoteUrl = $remoteUrl.replace(".git", ".wiki.git") + +$temporaryFolderName = "publishDocsTempFolder" + +git clone "https://gitlab-ci-token:$($token)@$($remoteUrl)" $temporaryFolderName +cd $temporaryFolderName +Remove-Item * +cp -r ../docs/* ./ +git add . +git commit -m "Docs: Documentation Update" +git push \ No newline at end of file diff --git a/src/Project.Tests/HomeControllerTests.cs b/src/Project.Tests/HomeControllerTests.cs new file mode 100644 index 0000000000000000000000000000000000000000..5cd8fd182ef632e9cf80a5d076cf8d316133968a --- /dev/null +++ b/src/Project.Tests/HomeControllerTests.cs @@ -0,0 +1,42 @@ +using NUnit.Framework; +using Coscine.Api.Project.Controllers; +using Microsoft.AspNetCore.Mvc; +using static Coscine.Api.Project.Controllers.ProjectController; + +namespace Coscine.Api.Project.Tests +{ + + [TestFixture] + public class HomeControllerTests + { + private readonly ProjectController _homeController = new ProjectController(); + + [Test] + public void GreetTest() + { + var name = "Laurin"; + + var result = _homeController.Store(name); + Assert.IsInstanceOf(result); + var okResult = (OkObjectResult)result; + + Assert.IsInstanceOf(okResult.Value); + var greeting = (Greeting)okResult.Value; + Assert.IsTrue(greeting.Username == name); + } + + [Test] + public void IndexTest() + { + var answer = "Hello World from a controller"; + + var result = _homeController.Index(); + Assert.IsInstanceOf(result); + var okResult = (OkObjectResult)result; + + Assert.IsInstanceOf(okResult.Value); + var answerFromController = (string)okResult.Value; + Assert.IsTrue(answerFromController == answer); + } + } +} diff --git a/src/Project.Tests/Project.Tests.csproj b/src/Project.Tests/Project.Tests.csproj new file mode 100644 index 0000000000000000000000000000000000000000..f0cef4c7f5b964b2ce1d83d219dc0195851c2385 --- /dev/null +++ b/src/Project.Tests/Project.Tests.csproj @@ -0,0 +1,253 @@ + + + + + + + Debug + AnyCPU + {EEE96892-A211-44EE-B2B8-11FAB31F2E26} + Library + Properties + Coscine.Api.Project.Tests + Coscine.Api.Project.Tests + v4.7.2 + 512 + true + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Microsoft.AspNetCore.Antiforgery.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Antiforgery.dll + + + ..\packages\Microsoft.AspNetCore.Authentication.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Authentication.Core.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Core.dll + + + ..\packages\Microsoft.AspNetCore.Authorization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authorization.dll + + + ..\packages\Microsoft.AspNetCore.Authorization.Policy.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authorization.Policy.dll + + + ..\packages\Microsoft.AspNetCore.Cryptography.Internal.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Cryptography.Internal.dll + + + ..\packages\Microsoft.AspNetCore.DataProtection.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.dll + + + ..\packages\Microsoft.AspNetCore.DataProtection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Diagnostics.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Diagnostics.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Hosting.Server.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Server.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Html.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Html.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Http.2.2.2\lib\netstandard2.0\Microsoft.AspNetCore.Http.dll + + + ..\packages\Microsoft.AspNetCore.Http.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Http.Extensions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Extensions.dll + + + ..\packages\Microsoft.AspNetCore.Http.Features.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Features.dll + + + ..\packages\Microsoft.AspNetCore.JsonPatch.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.JsonPatch.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Core.2.2.2\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Core.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.DataAnnotations.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.DataAnnotations.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Formatters.Json.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Formatters.Json.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.ViewFeatures.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.ViewFeatures.dll + + + ..\packages\Microsoft.AspNetCore.ResponseCaching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.ResponseCaching.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Routing.2.2.2\lib\netstandard2.0\Microsoft.AspNetCore.Routing.dll + + + ..\packages\Microsoft.AspNetCore.Routing.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Routing.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.WebUtilities.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.WebUtilities.dll + + + ..\packages\Microsoft.DotNet.PlatformAbstractions.2.1.0\lib\net45\Microsoft.DotNet.PlatformAbstractions.dll + + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.2.2.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.DependencyModel.2.1.0\lib\net451\Microsoft.Extensions.DependencyModel.dll + + + ..\packages\Microsoft.Extensions.FileProviders.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Hosting.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Localization.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Localization.dll + + + ..\packages\Microsoft.Extensions.Localization.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Localization.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Microsoft.Extensions.ObjectPool.2.2.0\lib\netstandard2.0\Microsoft.Extensions.ObjectPool.dll + + + ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll + + + ..\packages\Microsoft.Extensions.WebEncoders.2.2.0\lib\netstandard2.0\Microsoft.Extensions.WebEncoders.dll + + + ..\packages\Microsoft.Net.Http.Headers.2.2.0\lib\netstandard2.0\Microsoft.Net.Http.Headers.dll + + + ..\packages\Microsoft.Win32.Registry.4.5.0\lib\net461\Microsoft.Win32.Registry.dll + + + ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Newtonsoft.Json.Bson.1.0.2\lib\net45\Newtonsoft.Json.Bson.dll + + + ..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll + + + + ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll + + + + + + ..\packages\System.Diagnostics.DiagnosticSource.4.5.1\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + + ..\packages\System.Memory.4.5.2\lib\netstandard2.0\System.Memory.dll + + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + True + True + + + + ..\packages\System.Security.AccessControl.4.5.0\lib\net461\System.Security.AccessControl.dll + + + ..\packages\System.Security.Cryptography.Xml.4.5.0\lib\net461\System.Security.Cryptography.Xml.dll + + + ..\packages\System.Security.Permissions.4.5.0\lib\net461\System.Security.Permissions.dll + + + ..\packages\System.Security.Principal.Windows.4.5.1\lib\net461\System.Security.Principal.Windows.dll + + + + ..\packages\System.Text.Encodings.Web.4.5.0\lib\netstandard2.0\System.Text.Encodings.Web.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + + + + + + + + + + + + + + + + + + + {16c4eba5-ba87-45ec-ae1a-e8569a897959} + Project + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/src/Project.Tests/Properties/AssemblyInfo.cs b/src/Project.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000000000000000000000000000000000..5c5c129082ade5e89225b039d27ae2835fc65483 --- /dev/null +++ b/src/Project.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("api-demo.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("api-demo.Tests")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("eee96892-a211-44ee-b2b8-11fab31f2e26")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Project.Tests/app.config b/src/Project.Tests/app.config new file mode 100644 index 0000000000000000000000000000000000000000..776a83878fe2463915366fa94507c31df9560f9c --- /dev/null +++ b/src/Project.Tests/app.config @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Project.Tests/packages.config b/src/Project.Tests/packages.config new file mode 100644 index 0000000000000000000000000000000000000000..156ce30e9a4bd064258704b5169b93cb62ffcf39 --- /dev/null +++ b/src/Project.Tests/packages.config @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Project.sln b/src/Project.sln new file mode 100644 index 0000000000000000000000000000000000000000..9ca995957837dec82b0f967591d4a59dc55ab48f --- /dev/null +++ b/src/Project.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28803.156 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project", "Project\Project.csproj", "{16C4EBA5-BA87-45EC-AE1A-E8569A897959}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project.Tests", "Project.Tests\Project.Tests.csproj", "{EEE96892-A211-44EE-B2B8-11FAB31F2E26}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {16C4EBA5-BA87-45EC-AE1A-E8569A897959}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {16C4EBA5-BA87-45EC-AE1A-E8569A897959}.Debug|Any CPU.Build.0 = Debug|Any CPU + {16C4EBA5-BA87-45EC-AE1A-E8569A897959}.Release|Any CPU.ActiveCfg = Release|Any CPU + {16C4EBA5-BA87-45EC-AE1A-E8569A897959}.Release|Any CPU.Build.0 = Release|Any CPU + {EEE96892-A211-44EE-B2B8-11FAB31F2E26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EEE96892-A211-44EE-B2B8-11FAB31F2E26}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EEE96892-A211-44EE-B2B8-11FAB31F2E26}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EEE96892-A211-44EE-B2B8-11FAB31F2E26}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E7354F4B-ECD3-438A-82EE-71A82134E1AE} + EndGlobalSection +EndGlobal diff --git a/src/Project/App.config b/src/Project/App.config new file mode 100644 index 0000000000000000000000000000000000000000..c30f0694158ee58c3298770e2acb05bd67782f61 --- /dev/null +++ b/src/Project/App.config @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Project/ApplicationInformation.cs b/src/Project/ApplicationInformation.cs new file mode 100644 index 0000000000000000000000000000000000000000..114c53eeb2c719ba2843b08142a7e21c6efc3cfd --- /dev/null +++ b/src/Project/ApplicationInformation.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Net; + +namespace Coscine.Api.Project +{ + public class ApplicationInformation + { + public string AppName { get; set; } = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; + public string AppType { get; set; } = "apis"; + public Version Version { get; set; } = ToSemanticVersion(System.Reflection.Assembly.GetEntryAssembly().GetName().Version); + public string DomainName { get; set; } = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName; + public string HostName { get; set; } = Dns.GetHostName(); + public string PathPrefix { get; set; } = $"coscine/api/{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}"; + public Tuple PortRange = new Tuple(6001, 6999); + public int Port { get; set; } = 0; + public string AppBasePath { get { return $"coscine/{AppType}/{AppName}"; } } + public string TraefikBackendPath { get { return $"traefik/backends/{AppName}/servers/{HostName}"; } } + public string TraefikFrontendPath { get { return $"traefik/frontends/{AppName}"; } } + public Dictionary AppValues + { + get + { + return new Dictionary() + { + { $"{AppBasePath}/port", $"{Port}" }, + { $"{AppBasePath}/name", $"{AppName}" }, + { $"{AppBasePath}/version", $"{Version}" } + }; + } + } + public Dictionary TraefikValues + { + get + { + return new Dictionary() + { + { $"{TraefikBackendPath}/url", $"http://{HostName}.{DomainName}:{Port}"}, + { $"{TraefikBackendPath}/weight", $"{1}"}, + { $"{TraefikFrontendPath}/backend", AppName}, + { $"{TraefikFrontendPath}/routes/{AppName}/rule", $"Host:{HostName}.{DomainName};PathPrefix:/{PathPrefix}"} + }; + } + } + + private static Version ToSemanticVersion(Version version) + { + return new Version(version.Major, version.Minor, version.Build); + } + } +} diff --git a/src/Project/Authenticator.cs b/src/Project/Authenticator.cs new file mode 100644 index 0000000000000000000000000000000000000000..7f7d98a5112f9401cd66a9889e4604d33bc3c7fc --- /dev/null +++ b/src/Project/Authenticator.cs @@ -0,0 +1,37 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Coscine.Api.Project +{ + public class Authenticator + { + private readonly Controller _controller; + + public Authenticator(Controller controller) + { + _controller = controller; + } + + public bool ValidUser() + { + var bearer = _controller.Request.Headers["bearer"]; + if (!string.IsNullOrWhiteSpace(bearer)) + { + // Todo: Validate User + return true; + } + return false; + } + + // Todo: Add roles as parameter + public bool HasRequiredRights() + { + return true; + } + + } +} diff --git a/src/Project/Configurator.cs b/src/Project/Configurator.cs new file mode 100644 index 0000000000000000000000000000000000000000..354ba8ae2376d78d67ce28b4a7c70022fa465837 --- /dev/null +++ b/src/Project/Configurator.cs @@ -0,0 +1,96 @@ +using Coscine.Configuration; +using System.Collections.Generic; +using System.Linq; +using System.Net.NetworkInformation; + +namespace Coscine.Api.Project +{ + class Configurator + { + public ApplicationInformation ApplicationInformation { get; set; } = new ApplicationInformation(); + public IConfiguration Configuration { get; set; } + + public Configurator(ApplicationInformation applicationInforamtion, IConfiguration configuration) + { + ApplicationInformation = applicationInforamtion; + Configuration = configuration; + } + public Configurator(IConfiguration configuration) + { + Configuration = configuration; + } + + public void Register() + { + Register(ApplicationInformation); + } + + public void Register(ApplicationInformation applicationInformation) + { + // Default app values + var keys = Configuration.Keys(applicationInformation.AppBasePath); + + if (keys == null) + { + // No port overwrite + if (applicationInformation.Port == 0) + { + applicationInformation.Port = CalculatePort($"coscine/{applicationInformation.AppType}"); + } + + foreach (var kv in applicationInformation.AppValues.ToArray()) + { + Configuration.Put(kv.Key, kv.Value); + } + } + else + { + // No port overwrite + if (applicationInformation.Port == 0) { + int.TryParse(Configuration.GetString($"{applicationInformation.AppBasePath}/port"), out int port); + applicationInformation.Port = port; + } + } + + // Traefik Configuration + foreach (var kv in applicationInformation.TraefikValues.ToArray()) + { + Configuration.Put(kv.Key, kv.Value); + } + } + + private List GetUsedConsulPorts(string appsPrefix) + { + var ports = new List(); + var keys = Configuration.Keys(appsPrefix); + + if (keys != null) + { + foreach (var key in keys) + { + // maybe find a better solution + if (key.EndsWith("/port") && Configuration.Get(key) != null) + { + if (int.TryParse(Configuration.GetString(key), out int p)) + { + ports.Add(p); + } + } + } + } + return ports; + } + + private List GetUsedSystemPorts() + { + return IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections().Select(x => x.LocalEndPoint.Port).ToList(); + } + + private int CalculatePort(string appsPrefix) + { + var usedPorts = GetUsedConsulPorts(appsPrefix).Union(GetUsedSystemPorts()) + .OrderBy(x => x); + return Enumerable.Range(ApplicationInformation.PortRange.Item1, ApplicationInformation.PortRange.Item2 - ApplicationInformation.PortRange.Item1).Except(usedPorts).First(); + } + } +} diff --git a/src/Project/Controllers/ProjectController.cs b/src/Project/Controllers/ProjectController.cs new file mode 100644 index 0000000000000000000000000000000000000000..34c7a49a96e827f501c3e8b9eb39efc33ee71ca8 --- /dev/null +++ b/src/Project/Controllers/ProjectController.cs @@ -0,0 +1,46 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Coscine.Api.Project.Controllers +{ + public class ProjectController : Controller + { + private readonly Authenticator _authenticator; + + public ProjectController() + { + _authenticator = new Authenticator(this); + } + + [Route("[controller]")] + public IActionResult Index() + { + return Ok("Hello World from a controller"); + } + + //[Route("[controller]/greet/{username}")] would also work, but would take all commands + [HttpGet("[controller]/{id}")] + public IActionResult Get(string id) + { + return Ok(id); + } + + //[Route("[controller]/greet/{username}")] would also work, but would take all commands + [HttpPost("[controller]/{id}")] + public IActionResult Update(string id) + { + return Ok(id); + } + + [HttpPut("[controller]")] + public IActionResult Store() + { + return Ok(); + } + + [HttpPut("[controller]/{id}/resource/{resource_id}")] + public IActionResult AddResource(string id, string resource_id) + { + return Ok(id); + } + } +} diff --git a/src/Project/Controllers/ResourceController.cs b/src/Project/Controllers/ResourceController.cs new file mode 100644 index 0000000000000000000000000000000000000000..9b046ee5489e6b2b210869884b02bf0160847bd2 --- /dev/null +++ b/src/Project/Controllers/ResourceController.cs @@ -0,0 +1,47 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Coscine.Api.Project.Controllers +{ + public class ResourceController : Controller + { + private readonly Authenticator _authenticator; + + public ResourceController() + { + _authenticator = new Authenticator(this); + } + + [Route("[controller]")] + public IActionResult Index() + { + return Ok("Hello World from a controller"); + } + + + //[Route("[controller]/greet/{username}")] would also work, but would take all commands + [HttpGet("[controller]/{id}")] + public IActionResult Get(string id) + { + return Ok(id); + } + + //[Route("[controller]/greet/{username}")] would also work, but would take all commands + [HttpPost("[controller]/{id}")] + public IActionResult Update(string id) + { + return Ok(id); + } + + [HttpPut("[controller]")] + public IActionResult Store() + { + return Ok(); + } + + } +} diff --git a/src/Project/Models/Project.cs b/src/Project/Models/Project.cs new file mode 100644 index 0000000000000000000000000000000000000000..522dc0457516579642d8f8071d33e9c731a56239 --- /dev/null +++ b/src/Project/Models/Project.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Coscine.Api.Project.Models +{ + public class Projects + { + + // TODO: Implement checking + public bool OwnsProject(User user) + { + return true; + } + + } +} diff --git a/src/Project/Models/User.cs b/src/Project/Models/User.cs new file mode 100644 index 0000000000000000000000000000000000000000..22ad43c21888e71352ccb97e533400ad76a42570 --- /dev/null +++ b/src/Project/Models/User.cs @@ -0,0 +1,6 @@ +namespace Coscine.Api.Project.Models +{ + public class User + { + } +} \ No newline at end of file diff --git a/src/Project/Program.cs b/src/Project/Program.cs new file mode 100644 index 0000000000000000000000000000000000000000..11b1b5ccb1ba2a687de99a0aec45f83c281f59cd --- /dev/null +++ b/src/Project/Program.cs @@ -0,0 +1,29 @@ +using Coscine.Configuration; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; +using System.IO; + +namespace Coscine.Api.Project +{ + class Program + { + static void Main() + { + var configurator = new Configurator(new ConsulConfiguration()); + configurator.Register(); + var host = new WebHostBuilder() + + .ConfigureServices(services => + { + services.AddSingleton(new Startup(configurator.ApplicationInformation)); + }) + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseUrls($"http://[::]:{configurator.ApplicationInformation.Port}") + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/src/Project/Project.csproj b/src/Project/Project.csproj new file mode 100644 index 0000000000000000000000000000000000000000..8d1b28cb44c8e6aba2a3f61fdcc7b0737a831c9d --- /dev/null +++ b/src/Project/Project.csproj @@ -0,0 +1,555 @@ + + + + + + + + + + Debug + AnyCPU + {16C4EBA5-BA87-45EC-AE1A-E8569A897959} + Exe + Coscine.Api.Project + Coscine.Api.Project + v4.7.2 + 512 + true + true + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Consul.0.7.2.6\lib\net45\Consul.dll + + + ..\packages\Coscine.Configuration.1.4.0\lib\net461\Coscine.Configuration.dll + + + ..\packages\Microsoft.AspNetCore.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.dll + + + ..\packages\Microsoft.AspNetCore.Antiforgery.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Antiforgery.dll + + + ..\packages\Microsoft.AspNetCore.Authentication.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Authentication.Core.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Core.dll + + + ..\packages\Microsoft.AspNetCore.Authorization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authorization.dll + + + ..\packages\Microsoft.AspNetCore.Authorization.Policy.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authorization.Policy.dll + + + ..\packages\Microsoft.AspNetCore.Connections.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Connections.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Cors.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Cors.dll + + + ..\packages\Microsoft.AspNetCore.Cryptography.Internal.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Cryptography.Internal.dll + + + ..\packages\Microsoft.AspNetCore.DataProtection.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.dll + + + ..\packages\Microsoft.AspNetCore.DataProtection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Diagnostics.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Diagnostics.dll + + + ..\packages\Microsoft.AspNetCore.Diagnostics.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Diagnostics.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.HostFiltering.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.HostFiltering.dll + + + ..\packages\Microsoft.AspNetCore.Hosting.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.dll + + + ..\packages\Microsoft.AspNetCore.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Hosting.Server.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Server.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Html.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Html.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Http.2.2.2\lib\netstandard2.0\Microsoft.AspNetCore.Http.dll + + + ..\packages\Microsoft.AspNetCore.Http.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Http.Extensions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Extensions.dll + + + ..\packages\Microsoft.AspNetCore.Http.Features.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Features.dll + + + ..\packages\Microsoft.AspNetCore.HttpOverrides.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.HttpOverrides.dll + + + ..\packages\Microsoft.AspNetCore.JsonPatch.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.JsonPatch.dll + + + ..\packages\Microsoft.AspNetCore.Localization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Localization.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.ApiExplorer.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.ApiExplorer.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Core.2.2.2\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Core.dll + True + + + ..\packages\Microsoft.AspNetCore.Mvc.Cors.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Cors.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.DataAnnotations.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.DataAnnotations.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Formatters.Json.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Formatters.Json.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Localization.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Localization.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Razor.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.Razor.Extensions.2.2.0\lib\net46\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.RazorPages.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.RazorPages.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.TagHelpers.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.TagHelpers.dll + + + ..\packages\Microsoft.AspNetCore.Mvc.ViewFeatures.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.ViewFeatures.dll + + + ..\packages\Microsoft.AspNetCore.Razor.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Razor.dll + + + ..\packages\Microsoft.AspNetCore.Razor.Language.2.2.0\lib\net46\Microsoft.AspNetCore.Razor.Language.dll + + + ..\packages\Microsoft.AspNetCore.Razor.Runtime.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Razor.Runtime.dll + + + ..\packages\Microsoft.AspNetCore.ResponseCaching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.ResponseCaching.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Routing.2.2.2\lib\netstandard2.0\Microsoft.AspNetCore.Routing.dll + + + ..\packages\Microsoft.AspNetCore.Routing.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Routing.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Server.IIS.2.2.2\lib\netstandard2.0\Microsoft.AspNetCore.Server.IIS.dll + + + ..\packages\Microsoft.AspNetCore.Server.IISIntegration.2.2.1\lib\netstandard2.0\Microsoft.AspNetCore.Server.IISIntegration.dll + + + ..\packages\Microsoft.AspNetCore.Server.Kestrel.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Server.Kestrel.dll + + + ..\packages\Microsoft.AspNetCore.Server.Kestrel.Core.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Server.Kestrel.Core.dll + + + ..\packages\Microsoft.AspNetCore.Server.Kestrel.Https.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Server.Kestrel.Https.dll + + + ..\packages\Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.dll + + + ..\packages\Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.2.2.1\lib\netstandard2.0\Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.dll + + + ..\packages\Microsoft.AspNetCore.WebUtilities.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.WebUtilities.dll + + + ..\packages\Microsoft.CodeAnalysis.Common.3.0.0\lib\netstandard2.0\Microsoft.CodeAnalysis.dll + True + + + ..\packages\Microsoft.CodeAnalysis.CSharp.3.0.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll + True + + + ..\packages\Microsoft.CodeAnalysis.Razor.2.2.0\lib\net46\Microsoft.CodeAnalysis.Razor.dll + + + ..\packages\Microsoft.DotNet.PlatformAbstractions.2.1.0\lib\net45\Microsoft.DotNet.PlatformAbstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Caching.Memory.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll + + + ..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll + + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Configuration.Binder.2.2.4\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll + True + + + ..\packages\Microsoft.Extensions.Configuration.CommandLine.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.CommandLine.dll + + + ..\packages\Microsoft.Extensions.Configuration.EnvironmentVariables.2.2.4\lib\netstandard2.0\Microsoft.Extensions.Configuration.EnvironmentVariables.dll + True + + + ..\packages\Microsoft.Extensions.Configuration.FileExtensions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.FileExtensions.dll + + + ..\packages\Microsoft.Extensions.Configuration.Json.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Json.dll + + + ..\packages\Microsoft.Extensions.Configuration.UserSecrets.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.2.2.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.DependencyModel.2.1.0\lib\net451\Microsoft.Extensions.DependencyModel.dll + + + ..\packages\Microsoft.Extensions.FileProviders.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Abstractions.dll + + + ..\packages\Microsoft.Extensions.FileProviders.Composite.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Composite.dll + + + ..\packages\Microsoft.Extensions.FileProviders.Physical.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Physical.dll + + + ..\packages\Microsoft.Extensions.FileSystemGlobbing.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileSystemGlobbing.dll + + + ..\packages\Microsoft.Extensions.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Hosting.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Localization.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Localization.dll + + + ..\packages\Microsoft.Extensions.Localization.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Localization.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Configuration.dll + + + ..\packages\Microsoft.Extensions.Logging.Console.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Console.dll + + + ..\packages\Microsoft.Extensions.Logging.Debug.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Debug.dll + + + ..\packages\Microsoft.Extensions.Logging.EventSource.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.EventSource.dll + + + ..\packages\Microsoft.Extensions.ObjectPool.2.2.0\lib\netstandard2.0\Microsoft.Extensions.ObjectPool.dll + + + ..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Options.ConfigurationExtensions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.ConfigurationExtensions.dll + + + ..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll + + + ..\packages\Microsoft.Extensions.WebEncoders.2.2.0\lib\netstandard2.0\Microsoft.Extensions.WebEncoders.dll + + + ..\packages\Microsoft.Net.Http.Headers.2.2.0\lib\netstandard2.0\Microsoft.Net.Http.Headers.dll + + + ..\packages\Microsoft.Win32.Registry.4.5.0\lib\net461\Microsoft.Win32.Registry.dll + + + ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll + True + + + ..\packages\Newtonsoft.Json.Bson.1.0.2\lib\net45\Newtonsoft.Json.Bson.dll + True + + + + ..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll + True + True + + + ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll + + + + + ..\packages\System.Console.4.3.1\lib\net46\System.Console.dll + True + + + + + ..\packages\System.Diagnostics.DiagnosticSource.4.5.1\lib\net46\System.Diagnostics.DiagnosticSource.dll + True + + + ..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll + True + True + + + ..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll + True + True + + + + ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll + True + True + + + ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + True + True + + + ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + True + True + + + ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + True + True + + + ..\packages\System.IO.Pipelines.4.5.3\lib\netstandard2.0\System.IO.Pipelines.dll + True + + + ..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll + True + True + + + ..\packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll + True + True + + + ..\packages\System.Memory.4.5.2\lib\netstandard2.0\System.Memory.dll + True + + + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll + True + True + + + ..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll + + + ..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll + True + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + True + + + ..\packages\System.Runtime.Extensions.4.3.1\lib\net462\System.Runtime.Extensions.dll + True + + + ..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll + True + True + + + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + True + True + + + + ..\packages\System.Security.AccessControl.4.5.0\lib\net461\System.Security.AccessControl.dll + + + ..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll + True + + + ..\packages\System.Security.Cryptography.Cng.4.5.0\lib\net47\System.Security.Cryptography.Cng.dll + + + ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + True + + + ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + True + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + + + ..\packages\System.Security.Cryptography.Xml.4.5.0\lib\net461\System.Security.Cryptography.Xml.dll + + + ..\packages\System.Security.Permissions.4.5.0\lib\net461\System.Security.Permissions.dll + + + ..\packages\System.Security.Principal.Windows.4.5.1\lib\net461\System.Security.Principal.Windows.dll + True + + + + ..\packages\System.Text.Encoding.CodePages.4.5.1\lib\net461\System.Text.Encoding.CodePages.dll + True + + + ..\packages\System.Text.Encodings.Web.4.5.0\lib\netstandard2.0\System.Text.Encodings.Web.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + True + + + ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll + True + True + + + + ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + + + + + + + + + ..\packages\System.Xml.ReaderWriter.4.3.1\lib\net46\System.Xml.ReaderWriter.dll + True + + + ..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll + True + True + + + ..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll + True + True + + + ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll + True + True + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Project/Properties/AssemblyInfo.cs b/src/Project/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000000000000000000000000000000000..53781a8ae02a835d9575da54a340b396ffe7e5f6 --- /dev/null +++ b/src/Project/Properties/AssemblyInfo.cs @@ -0,0 +1,15 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Cake. +// +//------------------------------------------------------------------------------ +using System.Reflection; + +[assembly: AssemblyTitle("api-demo")] +[assembly: AssemblyCompany("RWTH Aachen University IT Center")] +[assembly: AssemblyProduct("api-demo")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] +[assembly: AssemblyCopyright("RWTH Aachen University IT Center 2019")] + diff --git a/src/Project/Startup.cs b/src/Project/Startup.cs new file mode 100644 index 0000000000000000000000000000000000000000..dcb47ba44231028bad93cfb4d3326da20700a537 --- /dev/null +++ b/src/Project/Startup.cs @@ -0,0 +1,43 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; + +namespace Coscine.Api.Project +{ + public class Startup + { + private readonly string _basePath; + public Startup(ApplicationInformation applicationInformation) + { + _basePath = $"/{applicationInformation.PathPrefix}"; + } + + public void ConfigureServices(IServiceCollection services) + { + services.AddMvc(); + } + + public void Configure(IApplicationBuilder app, IHostingEnvironment env) + { + app.UseForwardedHeaders(); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseExceptionHandler("/Home/Error"); + } + + app.UseCors(builder => builder + .AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader() + .AllowCredentials()); + + app.UsePathBase(_basePath); + app.UseMvc(); + } + } +} diff --git a/src/Project/packages.config b/src/Project/packages.config new file mode 100644 index 0000000000000000000000000000000000000000..3726d215cccd1666a806cc1a9f51c48889bf535e --- /dev/null +++ b/src/Project/packages.config @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file