diff --git a/StaticFiles.sln b/StaticFiles.sln index 426ca2a9f5..bead941055 100644 --- a/StaticFiles.sln +++ b/StaticFiles.sln @@ -1,25 +1,20 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26020.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{40EE0889-960E-41B4-A3D3-9CE963EB0797}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{8B21A3A9-9CA6-4857-A6E0-1A3203404B60}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.StaticFiles", "src\Microsoft.AspNetCore.StaticFiles\Microsoft.AspNetCore.StaticFiles.xproj", "{8D7BC5A4-F19C-4184-8338-A6B42997218C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.StaticFiles", "src\Microsoft.AspNetCore.StaticFiles\Microsoft.AspNetCore.StaticFiles.csproj", "{8D7BC5A4-F19C-4184-8338-A6B42997218C}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "StaticFileSample", "samples\StaticFileSample\StaticFileSample.xproj", "{092141D9-305A-4FC5-AE74-CB23982CA8D4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StaticFileSample", "samples\StaticFileSample\StaticFileSample.csproj", "{092141D9-305A-4FC5-AE74-CB23982CA8D4}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{EF02AFE8-7C15-4DDB-8B2C-58A676112A98}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.StaticFiles.Tests", "test\Microsoft.AspNetCore.StaticFiles.Tests\Microsoft.AspNetCore.StaticFiles.Tests.xproj", "{CC87FE7D-8F42-4BE9-A152-9625E837C1E5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.StaticFiles.Tests", "test\Microsoft.AspNetCore.StaticFiles.Tests\Microsoft.AspNetCore.StaticFiles.Tests.csproj", "{CC87FE7D-8F42-4BE9-A152-9625E837C1E5}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5EE39BF7-6457-432B-B26B-53B77A1C03D9}" - ProjectSection(SolutionItems) = preProject - global.json = global.json - EndProjectSection -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.StaticFiles.FunctionalTests", "test\Microsoft.AspNetCore.StaticFiles.FunctionalTests\Microsoft.AspNetCore.StaticFiles.FunctionalTests.xproj", "{FDF0539C-1F62-4B78-91B1-C687886931CA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.StaticFiles.FunctionalTests", "test\Microsoft.AspNetCore.StaticFiles.FunctionalTests\Microsoft.AspNetCore.StaticFiles.FunctionalTests.csproj", "{FDF0539C-1F62-4B78-91B1-C687886931CA}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/appveyor.yml b/appveyor.yml index be95b88d6f..2cdf2ca986 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,4 +10,6 @@ build_script: - build.cmd --quiet verify clone_depth: 1 test: off -deploy: off \ No newline at end of file +deploy: off +# Required for dotnet-test to work +os: Visual Studio 2015 diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..0605b59c01 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index 4fd7ede788..07997d6c83 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi diff --git a/tools/Key.snk b/build/Key.snk similarity index 100% rename from tools/Key.snk rename to build/Key.snk diff --git a/build/common.props b/build/common.props new file mode 100644 index 0000000000..5aaaae4eac --- /dev/null +++ b/build/common.props @@ -0,0 +1,20 @@ + + + + + + https://github.com/aspnet/StaticFiles + git + Microsoft ASP.NET Core + $(MSBuildThisFileDirectory)Key.snk + true + true + + + + + + \ No newline at end of file diff --git a/global.json b/global.json deleted file mode 100644 index 0ad1995dd2..0000000000 --- a/global.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "projects": [ - "src" - ], - "sdk": { - "version": "1.0.0-preview2-1-003180" - } -} \ No newline at end of file diff --git a/samples/StaticFileSample/StaticFileSample.csproj b/samples/StaticFileSample/StaticFileSample.csproj new file mode 100644 index 0000000000..1c6438a2eb --- /dev/null +++ b/samples/StaticFileSample/StaticFileSample.csproj @@ -0,0 +1,29 @@ + + + + net451;netcoreapp1.1 + Exe + win7-x64 + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + diff --git a/samples/StaticFileSample/StaticFileSample.xproj b/samples/StaticFileSample/StaticFileSample.xproj deleted file mode 100644 index 9a9e6322b3..0000000000 --- a/samples/StaticFileSample/StaticFileSample.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 092141d9-305a-4fc5-ae74-cb23982ca8d4 - .\obj - .\bin\ - - - 2.0 - 16758 - - - \ No newline at end of file diff --git a/samples/StaticFileSample/project.json b/samples/StaticFileSample/project.json deleted file mode 100644 index efd778b5fe..0000000000 --- a/samples/StaticFileSample/project.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": { - "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.AspNetCore.StaticFiles": "1.2.0-*", - "Microsoft.Extensions.Logging.Console": "1.2.0-*" - }, - "frameworks": { - "net451": {}, - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - } - }, - "publishOptions": { - "include": [ - "wwwroot", - "web.config" - ] - }, - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" - }, - "scripts": { - "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.StaticFiles/Microsoft.AspNetCore.StaticFiles.csproj b/src/Microsoft.AspNetCore.StaticFiles/Microsoft.AspNetCore.StaticFiles.csproj new file mode 100644 index 0000000000..4e189d4614 --- /dev/null +++ b/src/Microsoft.AspNetCore.StaticFiles/Microsoft.AspNetCore.StaticFiles.csproj @@ -0,0 +1,27 @@ + + + + + + ASP.NET Core static files middleware. Includes middleware for serving static files, directory browsing, and default files. + net451;netstandard1.3 + $(NoWarn);CS1591 + true + aspnetcore;staticfiles + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.StaticFiles/Microsoft.AspNetCore.StaticFiles.xproj b/src/Microsoft.AspNetCore.StaticFiles/Microsoft.AspNetCore.StaticFiles.xproj deleted file mode 100644 index f46c76bbd6..0000000000 --- a/src/Microsoft.AspNetCore.StaticFiles/Microsoft.AspNetCore.StaticFiles.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 8d7bc5a4-f19c-4184-8338-a6b42997218c - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.StaticFiles/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.StaticFiles/Properties/AssemblyInfo.cs index c220ac05ff..3af9731ac7 100644 --- a/src/Microsoft.AspNetCore.StaticFiles/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.StaticFiles/Properties/AssemblyInfo.cs @@ -1,13 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Reflection; -using System.Resources; using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Microsoft.AspNetCore.StaticFiles.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.StaticFiles/project.json b/src/Microsoft.AspNetCore.StaticFiles/project.json deleted file mode 100644 index 3628d936e0..0000000000 --- a/src/Microsoft.AspNetCore.StaticFiles/project.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "version": "1.2.0-*", - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true - }, - "description": "ASP.NET Core static files middleware. Includes middleware for serving static files, directory browsing, and default files.", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/staticfiles" - }, - "tags": [ - "aspnetcore", - "staticfiles" - ] - }, - "dependencies": { - "Microsoft.AspNetCore.Hosting.Abstractions": "1.2.0-*", - "Microsoft.AspNetCore.Http.Extensions": "1.2.0-*", - "Microsoft.Extensions.FileProviders.Abstractions": "1.2.0-*", - "Microsoft.Extensions.Logging.Abstractions": "1.2.0-*", - "Microsoft.Extensions.WebEncoders": "1.2.0-*", - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "net451": {}, - "netstandard1.3": {} - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.StaticFiles.FunctionalTests/Microsoft.AspNetCore.StaticFiles.FunctionalTests.csproj b/test/Microsoft.AspNetCore.StaticFiles.FunctionalTests/Microsoft.AspNetCore.StaticFiles.FunctionalTests.csproj new file mode 100644 index 0000000000..e922afd179 --- /dev/null +++ b/test/Microsoft.AspNetCore.StaticFiles.FunctionalTests/Microsoft.AspNetCore.StaticFiles.FunctionalTests.csproj @@ -0,0 +1,42 @@ + + + + + + netcoreapp1.1;net451 + win7-x64 + + + + + + + + PreserveNewest + + + PreserveNewest + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.AspNetCore.StaticFiles.FunctionalTests/Microsoft.AspNetCore.StaticFiles.FunctionalTests.xproj b/test/Microsoft.AspNetCore.StaticFiles.FunctionalTests/Microsoft.AspNetCore.StaticFiles.FunctionalTests.xproj deleted file mode 100644 index 2f710f589d..0000000000 --- a/test/Microsoft.AspNetCore.StaticFiles.FunctionalTests/Microsoft.AspNetCore.StaticFiles.FunctionalTests.xproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - fdf0539c-1f62-4b78-91b1-c687886931ca - .\obj - .\bin\ - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.StaticFiles.FunctionalTests/StaticFileMiddlewareTests.cs b/test/Microsoft.AspNetCore.StaticFiles.FunctionalTests/StaticFileMiddlewareTests.cs index c6d24e4bb1..056eff4af7 100644 --- a/test/Microsoft.AspNetCore.StaticFiles.FunctionalTests/StaticFileMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.StaticFiles.FunctionalTests/StaticFileMiddlewareTests.cs @@ -48,14 +48,14 @@ namespace Microsoft.AspNetCore.StaticFiles var baseAddress = "http://localhost:12345"; var builder = new WebHostBuilder() .UseKestrel() - .UseWebRoot(Directory.GetCurrentDirectory()) + .UseWebRoot(TestDirectory.BaseDirectory) .Configure(app => app.UseStaticFiles()); using (var server = builder.Start(baseAddress)) { using (var client = new HttpClient() { BaseAddress = new Uri(baseAddress) }) { - var last = File.GetLastWriteTimeUtc("TestDocument.txt"); + var last = File.GetLastWriteTimeUtc(Path.Combine(TestDirectory.BaseDirectory, "TestDocument.txt")); var response = await client.GetAsync("TestDocument.txt"); var trimed = new DateTimeOffset(last.Year, last.Month, last.Day, last.Hour, last.Minute, last.Second, TimeSpan.Zero).ToUniversalTime(); @@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.StaticFiles var baseAddress = "http://localhost:12345"; var builder = new WebHostBuilder() .UseKestrel() - .UseWebRoot(Path.Combine(Directory.GetCurrentDirectory(), baseDir)) + .UseWebRoot(Path.Combine(TestDirectory.BaseDirectory, baseDir)) .Configure(app => app.UseStaticFiles(new StaticFileOptions() { RequestPath = new PathString(baseUrl), @@ -127,7 +127,7 @@ namespace Microsoft.AspNetCore.StaticFiles var baseAddress = "http://localhost:12345"; var builder = new WebHostBuilder() .UseKestrel() - .UseWebRoot(Path.Combine(Directory.GetCurrentDirectory(), baseDir)) + .UseWebRoot(Path.Combine(TestDirectory.BaseDirectory, baseDir)) .Configure(app => app.UseStaticFiles(new StaticFileOptions() { RequestPath = new PathString(baseUrl), @@ -184,7 +184,7 @@ namespace Microsoft.AspNetCore.StaticFiles var responseComplete = new ManualResetEvent(false); Exception exception = null; var builder = new WebHostBuilder() - .UseWebRoot(Path.Combine(Directory.GetCurrentDirectory())) + .UseWebRoot(Path.Combine(TestDirectory.BaseDirectory)) .Configure(app => { app.Use(async (context, next) => diff --git a/test/Microsoft.AspNetCore.StaticFiles.FunctionalTests/project.json b/test/Microsoft.AspNetCore.StaticFiles.FunctionalTests/project.json deleted file mode 100644 index 4debd827ed..0000000000 --- a/test/Microsoft.AspNetCore.StaticFiles.FunctionalTests/project.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "copyToOutput": { - "include": [ - "SubFolder/**/*", - "TestDocument.txt", - "TestDocument1MB.txt" - ] - } - }, - "publishOptions": { - "include": [ - "SubFolder/**/*", - "TestDocument.txt" - ] - }, - "dependencies": { - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Server.IntegrationTesting": "0.3.0-*", - "Microsoft.AspNetCore.Server.HttpSys": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.AspNetCore.StaticFiles": "1.2.0-*", - "Microsoft.AspNetCore.Testing": "1.2.0-*", - "Microsoft.Extensions.Logging.Testing": "1.2.0-*", - "xunit": "2.2.0-*" - }, - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - }, - "net451": { - "frameworkAssemblies": { - "System.Net.Http": "" - } - } - }, - "testRunner": "xunit" -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.StaticFiles.Tests/DefaultFilesMiddlewareTests.cs b/test/Microsoft.AspNetCore.StaticFiles.Tests/DefaultFilesMiddlewareTests.cs index 040e7cc22f..3915a2f3e4 100644 --- a/test/Microsoft.AspNetCore.StaticFiles.Tests/DefaultFilesMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.StaticFiles.Tests/DefaultFilesMiddlewareTests.cs @@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.StaticFiles public async Task NoMatch_PassesThrough(string baseUrl, string baseDir, string requestUrl) { - using (var fileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), baseDir))) + using (var fileProvider = new PhysicalFileProvider(Path.Combine(TestDirectory.BaseDirectory, baseDir))) { var server = StaticFilesTestServer.Create(app => { @@ -91,7 +91,7 @@ namespace Microsoft.AspNetCore.StaticFiles public async Task FoundDirectoryWithDefaultFile_PathModified(string baseUrl, string baseDir, string requestUrl) { - using (var fileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), baseDir))) + using (var fileProvider = new PhysicalFileProvider(Path.Combine(TestDirectory.BaseDirectory, baseDir))) { var server = StaticFilesTestServer.Create(app => { @@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.StaticFiles public async Task NearMatch_RedirectAddSlash(string baseUrl, string baseDir, string requestUrl, string queryString) { - using (var fileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), baseDir))) + using (var fileProvider = new PhysicalFileProvider(Path.Combine(TestDirectory.BaseDirectory, baseDir))) { var server = StaticFilesTestServer.Create(app => app.UseDefaultFiles(new DefaultFilesOptions { @@ -168,7 +168,7 @@ namespace Microsoft.AspNetCore.StaticFiles public async Task PostDirectory_PassesThrough(string baseUrl, string baseDir, string requestUrl) { - using (var fileProvder = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), baseDir))) + using (var fileProvder = new PhysicalFileProvider(Path.Combine(TestDirectory.BaseDirectory, baseDir))) { var server = StaticFilesTestServer.Create(app => app.UseDefaultFiles(new DefaultFilesOptions { diff --git a/test/Microsoft.AspNetCore.StaticFiles.Tests/DirectoryBrowserMiddlewareTests.cs b/test/Microsoft.AspNetCore.StaticFiles.Tests/DirectoryBrowserMiddlewareTests.cs index 83f217ef94..e3a8ebdf94 100644 --- a/test/Microsoft.AspNetCore.StaticFiles.Tests/DirectoryBrowserMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.StaticFiles.Tests/DirectoryBrowserMiddlewareTests.cs @@ -72,7 +72,7 @@ namespace Microsoft.AspNetCore.StaticFiles public async Task NoMatch_PassesThrough(string baseUrl, string baseDir, string requestUrl) { - using (var fileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), baseDir))) + using (var fileProvider = new PhysicalFileProvider(Path.Combine(TestDirectory.BaseDirectory, baseDir))) { var server = StaticFilesTestServer.Create( app => app.UseDirectoryBrowser(new DirectoryBrowserOptions @@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.StaticFiles public async Task FoundDirectory_Served(string baseUrl, string baseDir, string requestUrl) { - using (var fileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), baseDir))) + using (var fileProvider = new PhysicalFileProvider(Path.Combine(TestDirectory.BaseDirectory, baseDir))) { var server = StaticFilesTestServer.Create( app => app.UseDirectoryBrowser(new DirectoryBrowserOptions @@ -151,7 +151,7 @@ namespace Microsoft.AspNetCore.StaticFiles public async Task NearMatch_RedirectAddSlash(string baseUrl, string baseDir, string requestUrl, string queryString) { - using (var fileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), baseDir))) + using (var fileProvider = new PhysicalFileProvider(Path.Combine(TestDirectory.BaseDirectory, baseDir))) { var server = StaticFilesTestServer.Create( app => app.UseDirectoryBrowser(new DirectoryBrowserOptions @@ -190,7 +190,7 @@ namespace Microsoft.AspNetCore.StaticFiles public async Task PostDirectory_PassesThrough(string baseUrl, string baseDir, string requestUrl) { - using (var fileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), baseDir))) + using (var fileProvider = new PhysicalFileProvider(Path.Combine(TestDirectory.BaseDirectory, baseDir))) { var server = StaticFilesTestServer.Create( app => app.UseDirectoryBrowser(new DirectoryBrowserOptions @@ -226,7 +226,7 @@ namespace Microsoft.AspNetCore.StaticFiles public async Task HeadDirectory_HeadersButNotBodyServed(string baseUrl, string baseDir, string requestUrl) { - using (var fileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), baseDir))) + using (var fileProvider = new PhysicalFileProvider(Path.Combine(TestDirectory.BaseDirectory, baseDir))) { var server = StaticFilesTestServer.Create( app => app.UseDirectoryBrowser(new DirectoryBrowserOptions diff --git a/test/Microsoft.AspNetCore.StaticFiles.Tests/Microsoft.AspNetCore.StaticFiles.Tests.csproj b/test/Microsoft.AspNetCore.StaticFiles.Tests/Microsoft.AspNetCore.StaticFiles.Tests.csproj new file mode 100644 index 0000000000..e0f2a700d3 --- /dev/null +++ b/test/Microsoft.AspNetCore.StaticFiles.Tests/Microsoft.AspNetCore.StaticFiles.Tests.csproj @@ -0,0 +1,37 @@ + + + + + + netcoreapp1.1;net451 + win7-x64 + + + + + + + + PreserveNewest + PreserveNewest + + + + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.AspNetCore.StaticFiles.Tests/Microsoft.AspNetCore.StaticFiles.Tests.xproj b/test/Microsoft.AspNetCore.StaticFiles.Tests/Microsoft.AspNetCore.StaticFiles.Tests.xproj deleted file mode 100644 index 52e6e5e559..0000000000 --- a/test/Microsoft.AspNetCore.StaticFiles.Tests/Microsoft.AspNetCore.StaticFiles.Tests.xproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - cc87fe7d-8f42-4be9-a152-9625e837c1e5 - .\obj - .\bin\ - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.StaticFiles.Tests/StaticFileMiddlewareTests.cs b/test/Microsoft.AspNetCore.StaticFiles.Tests/StaticFileMiddlewareTests.cs index a1008a0823..63e8016cff 100644 --- a/test/Microsoft.AspNetCore.StaticFiles.Tests/StaticFileMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.StaticFiles.Tests/StaticFileMiddlewareTests.cs @@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.StaticFiles [Fact] public async Task FoundFile_LastModifiedTrimsSeconds() { - using (var fileProvider = new PhysicalFileProvider(Directory.GetCurrentDirectory())) + using (var fileProvider = new PhysicalFileProvider(TestDirectory.BaseDirectory)) { var server = StaticFilesTestServer.Create(app => app.UseStaticFiles(new StaticFileOptions { @@ -86,7 +86,7 @@ namespace Microsoft.AspNetCore.StaticFiles public async Task FoundFile_Served(string baseUrl, string baseDir, string requestUrl) { - using (var fileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), baseDir))) + using (var fileProvider = new PhysicalFileProvider(Path.Combine(TestDirectory.BaseDirectory, baseDir))) { var server = StaticFilesTestServer.Create(app => app.UseStaticFiles(new StaticFileOptions { @@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.StaticFiles [MemberData(nameof(ExistingFiles))] public async Task HeadFile_HeadersButNotBodyServed(string baseUrl, string baseDir, string requestUrl) { - using (var fileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), baseDir))) + using (var fileProvider = new PhysicalFileProvider(Path.Combine(TestDirectory.BaseDirectory, baseDir))) { var server = StaticFilesTestServer.Create(app => app.UseStaticFiles(new StaticFileOptions { @@ -174,7 +174,7 @@ namespace Microsoft.AspNetCore.StaticFiles public async Task PassesThrough(string method, string baseUrl, string baseDir, string requestUrl) { - using (var fileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), baseDir))) + using (var fileProvider = new PhysicalFileProvider(Path.Combine(TestDirectory.BaseDirectory, baseDir))) { var server = StaticFilesTestServer.Create(app => app.UseStaticFiles(new StaticFileOptions { diff --git a/test/Microsoft.AspNetCore.StaticFiles.Tests/project.json b/test/Microsoft.AspNetCore.StaticFiles.Tests/project.json deleted file mode 100644 index 67de73c86e..0000000000 --- a/test/Microsoft.AspNetCore.StaticFiles.Tests/project.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "copyToOutput": { - "include": [ - "SubFolder/**/*", - "TestDocument.txt" - ] - } - }, - "publishOptions": { - "include": [ - "SubFolder/**/*", - "TestDocument.txt" - ] - }, - "dependencies": { - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.StaticFiles": "1.2.0-*", - "Microsoft.AspNetCore.TestHost": "1.2.0-*", - "Microsoft.AspNetCore.Testing": "1.2.0-*", - "Microsoft.Extensions.Logging.Testing": "1.2.0-*", - "xunit": "2.2.0-*" - }, - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - }, - "net451": {} - }, - "testRunner": "xunit" -} \ No newline at end of file diff --git a/test/shared/TestBaseDir.cs b/test/shared/TestBaseDir.cs new file mode 100644 index 0000000000..0e33ce8522 --- /dev/null +++ b/test/shared/TestBaseDir.cs @@ -0,0 +1,17 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.AspNetCore.StaticFiles +{ + public static class TestDirectory + { + public static readonly string BaseDirectory +#if NET451 + = AppDomain.CurrentDomain.BaseDirectory; +#else + = AppContext.BaseDirectory; +#endif + } +} \ No newline at end of file diff --git a/version.props b/version.props new file mode 100644 index 0000000000..51b1f4a6cd --- /dev/null +++ b/version.props @@ -0,0 +1,7 @@ + + + + 1.2.0 + preview1 + + \ No newline at end of file