diff --git a/build.ps1 b/build.ps1 index 71d423a099..6a5971f4f5 100644 --- a/build.ps1 +++ b/build.ps1 @@ -5,19 +5,52 @@ function Install-Dotnet if(($LASTEXITCODE -ne 0) -Or ((Test-Path Env:\APPVEYOR) -eq $true)) { Write-Host "Dotnet CLI not found - downloading latest version" - & { iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.ps1')) } + + # Prepare the dotnet CLI folder + $env:DOTNET_INSTALL_DIR="$(Convert-Path "$PSScriptRoot")\.dotnet\win7-x64" + if (!(Test-Path $env:DOTNET_INSTALL_DIR)) + { + mkdir $env:DOTNET_INSTALL_DIR | Out-Null + } + + # Download the dotnet CLI install script + if (!(Test-Path .\dotnet\install.ps1)) + { + Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.ps1" -OutFile ".\.dotnet\dotnet-install.ps1" + } + + # Run the dotnet CLI install + & .\.dotnet\dotnet-install.ps1 + + # Add the dotnet folder path to the process. This gets skipped + # by Install-DotNetCli if it's already installed. + Remove-PathVariable $env:DOTNET_INSTALL_DIR + $env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH" + } } +function Remove-PathVariable +{ + [cmdletbinding()] + param([string] $VariableToRemove) + $path = [Environment]::GetEnvironmentVariable("PATH", "User") + $newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove } + [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User") + $path = [Environment]::GetEnvironmentVariable("PATH", "Process") + $newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove } + [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process") +} + function Restore-Packages { param([string] $DirectoryName) - & dotnet restore -v Error ("""" + $DirectoryName + """") + & dotnet restore -v Warning ("""" + $DirectoryName + """") } function Test-Projects { - & dotnet test; + & dotnet test -c Release; if($LASTEXITCODE -ne 0) { exit 3 diff --git a/samples/Nancy.Demo.Hosting.Kestrel/HomeModule.cs b/samples/Nancy.Demo.Hosting.Kestrel/HomeModule.cs index 05dc19cd48..0c48b5893e 100644 --- a/samples/Nancy.Demo.Hosting.Kestrel/HomeModule.cs +++ b/samples/Nancy.Demo.Hosting.Kestrel/HomeModule.cs @@ -6,9 +6,9 @@ public class HomeModule : NancyModule { public HomeModule() { - Get["/"] = (o, token) => Task.FromResult("Hello from Nancy running on CoreCLR"); + Get("/", (args, ct) => Task.FromResult("Hello from Nancy running on CoreCLR")); - Get["/conneg/{name}"] = (parameters, token) => Task.FromResult(new Person() { Name = parameters.name }); + Get("/conneg/{name}", (args, token) => Task.FromResult(new Person() { Name = args.name })); } } } diff --git a/src/Nancy/project.json b/src/Nancy/project.json index fd2d064170..5891a08b75 100644 --- a/src/Nancy/project.json +++ b/src/Nancy/project.json @@ -16,6 +16,7 @@ "buildOptions": { "embed": [ + "ErrorHandling/Resources/**/*.*", "Diagnostics/Resources/**/*.*", "Diagnostics/Views/**/*.*" ] diff --git a/test/Nancy.Authentication.Basic.Tests/Nancy.Authentication.Basic.Tests.xproj b/test/Nancy.Authentication.Basic.Tests/Nancy.Authentication.Basic.Tests.xproj index 40bfe78438..b2b902baa9 100644 --- a/test/Nancy.Authentication.Basic.Tests/Nancy.Authentication.Basic.Tests.xproj +++ b/test/Nancy.Authentication.Basic.Tests/Nancy.Authentication.Basic.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.Authentication.Forms.Tests/Nancy.Authentication.Forms.Tests.xproj b/test/Nancy.Authentication.Forms.Tests/Nancy.Authentication.Forms.Tests.xproj index 39b586e635..43e3e0df66 100644 --- a/test/Nancy.Authentication.Forms.Tests/Nancy.Authentication.Forms.Tests.xproj +++ b/test/Nancy.Authentication.Forms.Tests/Nancy.Authentication.Forms.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.Embedded.Tests/Nancy.Embedded.Tests.xproj b/test/Nancy.Embedded.Tests/Nancy.Embedded.Tests.xproj index e58093ad19..68519e0513 100644 --- a/test/Nancy.Embedded.Tests/Nancy.Embedded.Tests.xproj +++ b/test/Nancy.Embedded.Tests/Nancy.Embedded.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.Encryption.MachineKey.Tests/Nancy.Encryption.MachineKey.Tests.xproj b/test/Nancy.Encryption.MachineKey.Tests/Nancy.Encryption.MachineKey.Tests.xproj index 267c8e0df5..f6638c677f 100644 --- a/test/Nancy.Encryption.MachineKey.Tests/Nancy.Encryption.MachineKey.Tests.xproj +++ b/test/Nancy.Encryption.MachineKey.Tests/Nancy.Encryption.MachineKey.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.Hosting.Aspnet.Tests/Nancy.Hosting.Aspnet.Tests.xproj b/test/Nancy.Hosting.Aspnet.Tests/Nancy.Hosting.Aspnet.Tests.xproj index 2a7e5c3eda..a86bdd20e6 100644 --- a/test/Nancy.Hosting.Aspnet.Tests/Nancy.Hosting.Aspnet.Tests.xproj +++ b/test/Nancy.Hosting.Aspnet.Tests/Nancy.Hosting.Aspnet.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.Hosting.Self.Tests/Nancy.Hosting.Self.Tests.xproj b/test/Nancy.Hosting.Self.Tests/Nancy.Hosting.Self.Tests.xproj index b66825ef94..4b2d50a0f6 100644 --- a/test/Nancy.Hosting.Self.Tests/Nancy.Hosting.Self.Tests.xproj +++ b/test/Nancy.Hosting.Self.Tests/Nancy.Hosting.Self.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.Metadata.Modules.Tests/Nancy.Metadata.Modules.Tests.xproj b/test/Nancy.Metadata.Modules.Tests/Nancy.Metadata.Modules.Tests.xproj index 4ce3381e56..fb3352961c 100644 --- a/test/Nancy.Metadata.Modules.Tests/Nancy.Metadata.Modules.Tests.xproj +++ b/test/Nancy.Metadata.Modules.Tests/Nancy.Metadata.Modules.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.Owin.Tests/AppBuilderExtensionsFixture.cs b/test/Nancy.Owin.Tests/AppBuilderExtensionsFixture.cs index d22a90a5f1..2834727d9f 100644 --- a/test/Nancy.Owin.Tests/AppBuilderExtensionsFixture.cs +++ b/test/Nancy.Owin.Tests/AppBuilderExtensionsFixture.cs @@ -2,18 +2,12 @@ { using System; using System.Collections.Generic; - using System.IO; - using System.Reflection; using System.Security.Cryptography.X509Certificates; using System.Text; using global::Owin; - using Microsoft.Owin.Testing; - using Nancy.Testing; - using Xunit; - using HttpStatusCode = Nancy.HttpStatusCode; public class AppBuilderExtensionsFixture @@ -41,7 +35,6 @@ public void When_host_Nancy_via_IAppBuilder_should_read_X509Certificate2() // Given var bootstrapper = new ConfigurableBootstrapper(config => config.Module()); - using (var server = TestServer.Create(app => app.UseNancy(opts => { opts.Bootstrapper = bootstrapper; @@ -65,7 +58,7 @@ public void When_host_Nancy_via_IAppBuilder_should_read_X509Certificate2() -----END CERTIFICATE----- "; - byte[] embeddedCert = Encoding.UTF8.GetBytes(cert); + var embeddedCert = Encoding.UTF8.GetBytes(cert); var env = new Dictionary() { @@ -73,30 +66,25 @@ public void When_host_Nancy_via_IAppBuilder_should_read_X509Certificate2() { "owin.RequestScheme", "http" }, { "owin.RequestHeaders", new Dictionary() { { "Host", new[] { "localhost" } } } }, { "owin.RequestMethod", "GET" }, - {"ssl.ClientCertificate", new X509Certificate(embeddedCert) } + { "owin.ResponseHeaders", new Dictionary() }, + { "ssl.ClientCertificate", new X509Certificate(embeddedCert) } }; - server.Invoke(env); + var result = server.Invoke(env); + result.Wait(); // Then Assert.Equal(env["owin.ResponseStatusCode"], 200); } } #endif - public class TestModule : NancyModule { public TestModule() { - Get["/"] = _ => - { - return HttpStatusCode.OK; - }; + Get("/", args => HttpStatusCode.OK); - Get("/ssl", args => - { - return this.Request.ClientCertificate != null ? 200 : 500; - }); + Get("/ssl", args => this.Request.ClientCertificate != null ? 200 : 500); } } } diff --git a/test/Nancy.Owin.Tests/Nancy.Owin.Tests.xproj b/test/Nancy.Owin.Tests/Nancy.Owin.Tests.xproj index c8385b286a..9414b1968c 100644 --- a/test/Nancy.Owin.Tests/Nancy.Owin.Tests.xproj +++ b/test/Nancy.Owin.Tests/Nancy.Owin.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.Testing.Tests/Nancy.Testing.Tests.xproj b/test/Nancy.Testing.Tests/Nancy.Testing.Tests.xproj index eeef0a7f39..ffa1197064 100644 --- a/test/Nancy.Testing.Tests/Nancy.Testing.Tests.xproj +++ b/test/Nancy.Testing.Tests/Nancy.Testing.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.Tests.Functional/Nancy.Tests.Functional.xproj b/test/Nancy.Tests.Functional/Nancy.Tests.Functional.xproj index c25bf47097..35861b15d4 100644 --- a/test/Nancy.Tests.Functional/Nancy.Tests.Functional.xproj +++ b/test/Nancy.Tests.Functional/Nancy.Tests.Functional.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.Tests/Nancy.Tests.xproj b/test/Nancy.Tests/Nancy.Tests.xproj index 221bd9c4d2..609bbe4601 100644 --- a/test/Nancy.Tests/Nancy.Tests.xproj +++ b/test/Nancy.Tests/Nancy.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.Validation.DataAnnotatioins.Tests/Nancy.Validation.DataAnnotatioins.Tests.xproj b/test/Nancy.Validation.DataAnnotatioins.Tests/Nancy.Validation.DataAnnotatioins.Tests.xproj index e5da6d4f26..806196280d 100644 --- a/test/Nancy.Validation.DataAnnotatioins.Tests/Nancy.Validation.DataAnnotatioins.Tests.xproj +++ b/test/Nancy.Validation.DataAnnotatioins.Tests/Nancy.Validation.DataAnnotatioins.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.Validation.FluentValidation.Tests/Nancy.Validation.FluentValidation.Tests.xproj b/test/Nancy.Validation.FluentValidation.Tests/Nancy.Validation.FluentValidation.Tests.xproj index 11a215e321..e5671a3185 100644 --- a/test/Nancy.Validation.FluentValidation.Tests/Nancy.Validation.FluentValidation.Tests.xproj +++ b/test/Nancy.Validation.FluentValidation.Tests/Nancy.Validation.FluentValidation.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.ViewEngines.DotLiquid.Tests/Nancy.ViewEngines.DotLiquid.Tests.xproj b/test/Nancy.ViewEngines.DotLiquid.Tests/Nancy.ViewEngines.DotLiquid.Tests.xproj index 358b864eb7..f76a613c22 100644 --- a/test/Nancy.ViewEngines.DotLiquid.Tests/Nancy.ViewEngines.DotLiquid.Tests.xproj +++ b/test/Nancy.ViewEngines.DotLiquid.Tests/Nancy.ViewEngines.DotLiquid.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.ViewEngines.Markdown.Tests/Nancy.ViewEngines.Markdown.Tests.xproj b/test/Nancy.ViewEngines.Markdown.Tests/Nancy.ViewEngines.Markdown.Tests.xproj index 1ea867e1d5..f977a09614 100644 --- a/test/Nancy.ViewEngines.Markdown.Tests/Nancy.ViewEngines.Markdown.Tests.xproj +++ b/test/Nancy.ViewEngines.Markdown.Tests/Nancy.ViewEngines.Markdown.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file diff --git a/test/Nancy.ViewEngines.Razor.Tests/Nancy.ViewEngines.Razor.Tests.xproj b/test/Nancy.ViewEngines.Razor.Tests/Nancy.ViewEngines.Razor.Tests.xproj index f1e3035214..0893a7bd41 100644 --- a/test/Nancy.ViewEngines.Razor.Tests/Nancy.ViewEngines.Razor.Tests.xproj +++ b/test/Nancy.ViewEngines.Razor.Tests/Nancy.ViewEngines.Razor.Tests.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -16,5 +16,8 @@ 2.0 + + + - + \ No newline at end of file