зеркало из https://github.com/dotnet/aspnetcore.git
* Updating project structure to use the src, test, build, samples format
* Adding build scripts to use K compilation.
This commit is contained in:
Родитель
5f4807dc9e
Коммит
7b8a54cc24
|
@ -25,3 +25,4 @@ PublishProfiles/
|
|||
*.log
|
||||
*.vspx
|
||||
/.symbols
|
||||
nuget.exe
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
using System;
|
||||
using System.Runtime.Caching;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Owin.FileSystems;
|
||||
|
||||
namespace Microsoft.AspNet.CoreServices
|
||||
{
|
||||
public class CompilerCache
|
||||
{
|
||||
private readonly MemoryCache _cache;
|
||||
|
||||
public CompilerCache()
|
||||
{
|
||||
_cache = MemoryCache.Default;
|
||||
}
|
||||
|
||||
public Task<CompilationResult> GetOrAdd(IFileInfo file, Func<Task<CompilationResult>> compile)
|
||||
{
|
||||
// Generate a content id
|
||||
string contentId = file.PhysicalPath + '|' + file.LastModified.Ticks;
|
||||
|
||||
var cachedType = _cache[contentId] as Type;
|
||||
if (cachedType == null)
|
||||
{
|
||||
return CompileWith(contentId, file, compile);
|
||||
}
|
||||
|
||||
return Task.FromResult(CompilationResult.Successful(generatedCode: null, type: cachedType));
|
||||
}
|
||||
|
||||
private async Task<CompilationResult> CompileWith(string contentId, IFileInfo file, Func<Task<CompilationResult>> compile)
|
||||
{
|
||||
CompilationResult result = await compile();
|
||||
Type compiledType = result.CompiledType;
|
||||
|
||||
var filePaths = new [] { file.PhysicalPath };
|
||||
var policy = new CacheItemPolicy();
|
||||
policy.ChangeMonitors.Add(new HostFileChangeMonitor(filePaths));
|
||||
|
||||
_cache.Set(contentId, result.CompiledType, policy);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"dependencies": [],
|
||||
"configurations": [
|
||||
{ "net45": {} },
|
||||
{ "k10": {} }
|
||||
]
|
||||
}
|
|
@ -3,13 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.21005.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc", "Microsoft.AspNet.Mvc\Microsoft.AspNet.Mvc.csproj", "{2A0C26F1-0240-4AE1-AE00-4691C291B122}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc", "src\Microsoft.AspNet.Mvc\Microsoft.AspNet.Mvc.csproj", "{2A0C26F1-0240-4AE1-AE00-4691C291B122}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvcSample", "MvcSample\MvcSample.csproj", "{069EA0A1-BB68-41D1-A973-3429EC09264C}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvcSample", "samples\MvcSample\MvcSample.csproj", "{069EA0A1-BB68-41D1-A973-3429EC09264C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.CoreServices", "Microsoft.AspNet.CoreServices\Microsoft.AspNet.CoreServices.csproj", "{EC38534C-A2D1-413F-97D1-55EEF5D2FB71}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.CoreServices", "src\Microsoft.AspNet.CoreServices\Microsoft.AspNet.CoreServices.csproj", "{EC38534C-A2D1-413F-97D1-55EEF5D2FB71}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.Razor", "Microsoft.AspNet.Mvc.Razor\Microsoft.AspNet.Mvc.Razor.csproj", "{224A14D0-ECA7-441C-AE89-B6E66A57EF9B}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.Razor", "src\Microsoft.AspNet.Mvc.Razor\Microsoft.AspNet.Mvc.Razor.csproj", "{224A14D0-ECA7-441C-AE89-B6E66A57EF9B}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{DAAE4C74-D06F-4874-A166-33305D2643CE}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{32285FA4-6B46-4D6B-A840-2B13E4C8B58E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -37,4 +41,10 @@ Global
|
|||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{069EA0A1-BB68-41D1-A973-3429EC09264C} = {DAAE4C74-D06F-4874-A166-33305D2643CE}
|
||||
{EC38534C-A2D1-413F-97D1-55EEF5D2FB71} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
|
||||
{2A0C26F1-0240-4AE1-AE00-4691C291B122} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
|
||||
{224A14D0-ECA7-441C-AE89-B6E66A57EF9B} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
@echo off
|
||||
cd %~dp0
|
||||
|
||||
IF EXIST .nuget\NuGet.exe goto part2
|
||||
echo Downloading latest version of NuGet.exe...
|
||||
md .nuget
|
||||
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '.nuget\NuGet.exe'"
|
||||
|
||||
:part2
|
||||
.nuget\NuGet.exe install Sake -version 0.2 -o packages
|
||||
packages\Sake.0.2\tools\Sake.exe -I build -f makefile.shade %*
|
|
@ -0,0 +1,17 @@
|
|||
@{/*
|
||||
|
||||
k-build
|
||||
Builds project. Downloads and executes k sdk tools.
|
||||
|
||||
projectFile=''
|
||||
Required. Path to the project.json to build.
|
||||
|
||||
*/}
|
||||
|
||||
var projectFolder='${Path.GetDirectoryName(projectFile)}'
|
||||
var projectName='${Path.GetFileName(projectFolder)}'
|
||||
var projectBin='${Path.Combine(projectFolder, "bin")}'
|
||||
|
||||
-// directory delete="${projectBin}"
|
||||
k command='build ${projectFolder}'
|
||||
copy sourceDir='${projectBin}' outputDir='${Path.Combine(BUILD_DIR, projectName)}'
|
|
@ -0,0 +1,13 @@
|
|||
@{/*
|
||||
|
||||
k-clean
|
||||
Cleans project. Downloads and executes k sdk tools.
|
||||
|
||||
projectFile=''
|
||||
Required. Path to the project.json to build.
|
||||
|
||||
*/}
|
||||
|
||||
var projectFolder='${Path.GetDirectoryName(projectFile)}'
|
||||
|
||||
k command='clean ${projectFolder}'
|
|
@ -0,0 +1,43 @@
|
|||
use namespace="System"
|
||||
use namespace="System.IO"
|
||||
use import="Files"
|
||||
|
||||
default BASE_DIR='${Directory.GetCurrentDirectory()}'
|
||||
default TARGET_DIR='${Path.Combine(BASE_DIR, "artifacts")}'
|
||||
default BUILD_DIR='${Path.Combine(TARGET_DIR, "build")}'
|
||||
default TEST_DIR='${Path.Combine(TARGET_DIR, "test")}'
|
||||
|
||||
@{
|
||||
E("K_BUILD_VERSION", "t" + DateTime.UtcNow.ToString("yyMMddHHmmss"));
|
||||
}
|
||||
|
||||
#target-dir-clean target="clean"
|
||||
directory delete="${TARGET_DIR}"
|
||||
|
||||
#build-clean target='clean'
|
||||
k-clean each='var projectFile in Files.Include("src/**/project.json")'
|
||||
|
||||
#build-compile target='compile'
|
||||
k-build each='var projectFile in Files.Include("src/**/project.json")'
|
||||
@{
|
||||
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg")))
|
||||
{
|
||||
File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true);
|
||||
}
|
||||
}
|
||||
|
||||
#nuget-install target='install' description='Copy NuGet packages to local repo'
|
||||
@{
|
||||
var HOME_DIR = E("HOME");
|
||||
if (string.IsNullOrEmpty(HOME_DIR))
|
||||
{
|
||||
HOME_DIR = E("HOMEDRIVE") + E("HOMEPATH");
|
||||
}
|
||||
}
|
||||
copy sourceDir='${BUILD_DIR}' include='*.nupkg' outputDir='${Path.Combine(HOME_DIR, ".nuget")}' overwrite='${true}'
|
||||
|
||||
|
||||
functions @{
|
||||
string E(string key) { return Environment.GetEnvironmentVariable(key); }
|
||||
void E(string key, string value) { Environment.SetEnvironmentVariable(key, value); }
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
@{/*
|
||||
|
||||
k
|
||||
Run klr commands in your project. Downloads and executes k sdk.
|
||||
|
||||
kVersion='0.0.1-pre-30109-087'
|
||||
May be passed to override the nuget package version holding xunit console runner.
|
||||
|
||||
kProgram='...'
|
||||
May be passed to override the path to the xunit program that will be executed
|
||||
|
||||
command=''
|
||||
|
||||
*/}
|
||||
|
||||
default kLatestSuccessful='\\wsr-teamcity\Drops\ProjectK.Main\latest-successful\sdk'
|
||||
default kVersion=''
|
||||
|
||||
test if='string.IsNullOrEmpty(kVersion)'
|
||||
for each='var file in System.IO.Directory.EnumerateFiles(kLatestSuccessful).Select(System.IO.Path.GetFileName)'
|
||||
test if='file.StartsWith("ProjectK.") && file.EndsWith(".nupkg")'
|
||||
- kVersion = file.Substring("ProjectK.".Length, file.Length - "ProjectK.".Length - ".nupkg".Length);
|
||||
|
||||
default kProgram='packages/ProjectK.${kVersion}/tools/k.cmd'
|
||||
|
||||
-// Download xunit from nuget sources if not already present
|
||||
test if='!File.Exists(kProgram)'
|
||||
log info='Installing ProjectK ${kVersion} from ${kLatestSuccessful}'
|
||||
nuget-install package='ProjectK' packageVersion='${kVersion}' outputDir='packages' extra='-Source ${kLatestSuccessful}'
|
||||
|
||||
exec program='${Path.GetFullPath(kProgram)}' commandline='${command}'
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
var VERSION='0.1'
|
||||
var FULL_VERSION='0.1'
|
||||
var AUTHORS='Microsoft'
|
||||
|
||||
use-standard-lifecycle
|
||||
k-standard-goals
|
|
@ -41,21 +41,21 @@
|
|||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Owin, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||
<HintPath>..\..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Diagnostics">
|
||||
<HintPath>..\packages\Microsoft.Owin.Diagnostics.2.0.2\lib\net40\Microsoft.Owin.Diagnostics.dll</HintPath>
|
||||
<HintPath>..\..\packages\Microsoft.Owin.Diagnostics.2.0.2\lib\net40\Microsoft.Owin.Diagnostics.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.FileSystems, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.Owin.FileSystems.2.1.0-rc1\lib\net40\Microsoft.Owin.FileSystems.dll</HintPath>
|
||||
<HintPath>..\..\packages\Microsoft.Owin.FileSystems.2.1.0-rc1\lib\net40\Microsoft.Owin.FileSystems.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Owin">
|
||||
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||
<HintPath>..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
@ -76,15 +76,15 @@
|
|||
<Compile Include="Startup.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.AspNet.CoreServices\Microsoft.AspNet.CoreServices.csproj">
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNet.CoreServices\Microsoft.AspNet.CoreServices.csproj">
|
||||
<Project>{ec38534c-a2d1-413f-97d1-55eef5d2fb71}</Project>
|
||||
<Name>Microsoft.AspNet.CoreServices</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Microsoft.AspNet.Mvc.Razor\Microsoft.AspNet.Mvc.Razor.csproj">
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNet.Mvc.Razor\Microsoft.AspNet.Mvc.Razor.csproj">
|
||||
<Project>{224a14d0-eca7-441c-ae89-b6e66a57ef9b}</Project>
|
||||
<Name>Microsoft.AspNet.Mvc.Razor</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Microsoft.AspNet.Mvc\Microsoft.AspNet.Mvc.csproj">
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNet.Mvc\Microsoft.AspNet.Mvc.csproj">
|
||||
<Project>{2a0c26f1-0240-4ae1-ae00-4691c291b122}</Project>
|
||||
<Name>Microsoft.AspNet.Mvc</Name>
|
||||
</ProjectReference>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
|
||||
<system.web>
|
||||
<compilation debug="true" targetFramework="4.5" />
|
||||
<httpRuntime targetFramework="4.5" />
|
||||
</system.web>
|
||||
|
||||
</configuration>
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Owin.FileSystems;
|
||||
|
||||
namespace Microsoft.AspNet.CoreServices
|
||||
{
|
||||
public class CompilerCache
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, Type> _cache;
|
||||
|
||||
public CompilerCache()
|
||||
{
|
||||
_cache = new ConcurrentDictionary<string,Type>(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public async Task<CompilationResult> GetOrAdd(IFileInfo file, Func<Task<CompilationResult>> compile)
|
||||
{
|
||||
// Generate a content id
|
||||
string contentId = file.PhysicalPath + '|' + file.LastModified.Ticks;
|
||||
|
||||
Type compiledType;
|
||||
if (!_cache.TryGetValue(contentId, out compiledType))
|
||||
{
|
||||
CompilationResult result = await compile();
|
||||
_cache.TryAdd(contentId, result.CompiledType);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return CompilationResult.Successful(generatedCode: null, type: compiledType);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,11 +31,10 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Owin.FileSystems">
|
||||
<HintPath>..\packages\Microsoft.Owin.FileSystems.2.1.0-rc1\lib\net40\Microsoft.Owin.FileSystems.dll</HintPath>
|
||||
<HintPath>..\..\packages\Microsoft.Owin.FileSystems.2.1.0-rc1\lib\net40\Microsoft.Owin.FileSystems.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Runtime.Caching" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ActivatorUtilities.cs" />
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"dependencies": [
|
||||
{ "Microsoft.Owin.FileSystems": { "version": "2.0.2" } }
|
||||
],
|
||||
"configurations": [
|
||||
{ "net45": {} },
|
||||
{ "k10": {} }
|
||||
]
|
||||
}
|
|
@ -32,14 +32,14 @@
|
|||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Owin, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||
<HintPath>..\..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.FileSystems">
|
||||
<HintPath>..\packages\Microsoft.Owin.FileSystems.2.1.0-rc1\lib\net40\Microsoft.Owin.FileSystems.dll</HintPath>
|
||||
<HintPath>..\..\packages\Microsoft.Owin.FileSystems.2.1.0-rc1\lib\net40\Microsoft.Owin.FileSystems.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||
<HintPath>..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"dependencies": [
|
||||
{ "Owin": { "version": "1.0" } },
|
||||
{ "Newtonsoft.Json": { "version": "4.5.11" } },
|
||||
{ "Microsoft.Owin": { "version": "2.0.2" } },
|
||||
{ "Microsoft.Owin.FileSystems": { "version": "2.0.2" } },
|
||||
{ "Microsoft.AspNet.WebApi.Client": { "version": "5.0.0" } },
|
||||
{ "Microsoft.AspNet.CoreServices" : { } }
|
||||
],
|
||||
"configurations": [
|
||||
{ "net45": {
|
||||
"dependencies": [
|
||||
{ "System.Net.Http" : { } }
|
||||
]
|
||||
},
|
||||
"k10" : { }
|
||||
}
|
||||
]
|
||||
}
|
|
@ -31,13 +31,13 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Owin">
|
||||
<HintPath>..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||
<HintPath>..\..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Owin">
|
||||
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||
<HintPath>..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче