initial commit
This commit is contained in:
Родитель
7a2f5e8661
Коммит
655c84e7ac
|
@ -0,0 +1,51 @@
|
|||
*.doc diff=astextplain
|
||||
*.DOC diff=astextplain
|
||||
*.docx diff=astextplain
|
||||
*.DOCX diff=astextplain
|
||||
*.dot diff=astextplain
|
||||
*.DOT diff=astextplain
|
||||
*.pdf diff=astextplain
|
||||
*.PDF diff=astextplain
|
||||
*.rtf diff=astextplain
|
||||
*.RTF diff=astextplain
|
||||
|
||||
*.jpg binary
|
||||
*.png binary
|
||||
*.gif binary
|
||||
|
||||
*.cs text=auto diff=csharp
|
||||
*.vb text=auto
|
||||
*.resx text=auto
|
||||
*.c text=auto
|
||||
*.cpp text=auto
|
||||
*.cxx text=auto
|
||||
*.h text=auto
|
||||
*.hxx text=auto
|
||||
*.py text=auto
|
||||
*.rb text=auto
|
||||
*.java text=auto
|
||||
*.html text=auto
|
||||
*.htm text=auto
|
||||
*.css text=auto
|
||||
*.scss text=auto
|
||||
*.sass text=auto
|
||||
*.less text=auto
|
||||
*.js text=auto
|
||||
*.lisp text=auto
|
||||
*.clj text=auto
|
||||
*.sql text=auto
|
||||
*.php text=auto
|
||||
*.lua text=auto
|
||||
*.m text=auto
|
||||
*.asm text=auto
|
||||
*.erl text=auto
|
||||
*.fs text=auto
|
||||
*.fsx text=auto
|
||||
*.hs text=auto
|
||||
|
||||
*.csproj text=auto
|
||||
*.vbproj text=auto
|
||||
*.fsproj text=auto
|
||||
*.dbproj text=auto
|
||||
*.sln text=auto eol=crlf
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
[Oo]bj/
|
||||
[Bb]in/
|
||||
TestResults/
|
||||
.nuget/
|
||||
*.sln.ide/
|
||||
_ReSharper.*/
|
||||
packages/
|
||||
artifacts/
|
||||
PublishProfiles/
|
||||
*.user
|
||||
*.suo
|
||||
*.cache
|
||||
*.docstates
|
||||
_ReSharper.*
|
||||
nuget.exe
|
||||
project.lock.json
|
||||
*net45.csproj
|
||||
*net451.csproj
|
||||
*k10.csproj
|
||||
*.psess
|
||||
*.vsp
|
||||
*.pidb
|
||||
*.userprefs
|
||||
*DS_Store
|
||||
*.ncrunchsolution
|
||||
*.*sdf
|
||||
*.ipch
|
||||
.vs/
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.23107.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.VisualStudio.Web.BrowserLink.Loader", "src\Microsoft.VisualStudio.Web.BrowserLink.Loader\Microsoft.VisualStudio.Web.BrowserLink.Loader.xproj", "{C31202E6-FC58-4354-B2D2-ACD1B3118C05}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C31202E6-FC58-4354-B2D2-ACD1B3118C05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C31202E6-FC58-4354-B2D2-ACD1B3118C05}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C31202E6-FC58-4354-B2D2-ACD1B3118C05}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C31202E6-FC58-4354-B2D2-ACD1B3118C05}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/api/v2" />
|
||||
<add key="NuGet.org" value="https://nuget.org/api/v2/" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
@echo off
|
||||
cd %~dp0
|
||||
|
||||
SETLOCAL
|
||||
SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe
|
||||
|
||||
IF EXIST %CACHED_NUGET% goto copynuget
|
||||
echo Downloading latest version of NuGet.exe...
|
||||
IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet
|
||||
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '%CACHED_NUGET%'"
|
||||
|
||||
:copynuget
|
||||
IF EXIST .nuget\nuget.exe goto restore
|
||||
md .nuget
|
||||
copy %CACHED_NUGET% .nuget\nuget.exe > nul
|
||||
|
||||
:restore
|
||||
IF EXIST packages\KoreBuild goto run
|
||||
.nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre
|
||||
.nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion
|
||||
|
||||
IF "%SKIP_DNX_INSTALL%"=="1" goto run
|
||||
CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86
|
||||
CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -arch x86
|
||||
|
||||
:run
|
||||
CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86
|
||||
packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %*
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if test `uname` = Darwin; then
|
||||
cachedir=~/Library/Caches/KBuild
|
||||
else
|
||||
if [ -z $XDG_DATA_HOME ]; then
|
||||
cachedir=$HOME/.local/share
|
||||
else
|
||||
cachedir=$XDG_DATA_HOME;
|
||||
fi
|
||||
fi
|
||||
mkdir -p $cachedir
|
||||
|
||||
url=https://www.nuget.org/nuget.exe
|
||||
|
||||
if test ! -f $cachedir/nuget.exe; then
|
||||
wget -O $cachedir/nuget.exe $url 2>/dev/null || curl -o $cachedir/nuget.exe --location $url /dev/null
|
||||
fi
|
||||
|
||||
if test ! -e .nuget; then
|
||||
mkdir .nuget
|
||||
cp $cachedir/nuget.exe .nuget/nuget.exe
|
||||
fi
|
||||
|
||||
if test ! -d packages/KoreBuild; then
|
||||
mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre
|
||||
mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion
|
||||
fi
|
||||
|
||||
if ! type dnvm > /dev/null 2>&1; then
|
||||
source packages/KoreBuild/build/dnvm.sh
|
||||
fi
|
||||
|
||||
if ! type dnx > /dev/null 2>&1; then
|
||||
dnvm upgrade
|
||||
fi
|
||||
|
||||
mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@"
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"projects": [ "src" ]
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
use namespace="System.Net"
|
||||
|
||||
var VERSION='0.1'
|
||||
var FULL_VERSION='0.1'
|
||||
var AUTHORS='Microsoft Open Technologies, Inc.'
|
||||
|
||||
use-standard-lifecycle
|
||||
k-standard-goals
|
|
@ -0,0 +1,41 @@
|
|||
// 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;
|
||||
using Microsoft.VisualStudio.Web.BrowserLink.Loader;
|
||||
|
||||
namespace Microsoft.AspNet.Builder
|
||||
{
|
||||
public static class BrowserLinkLoaderExtensions
|
||||
{
|
||||
public static IApplicationBuilder UseBrowserLink(this IApplicationBuilder app)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsMicrosoftRuntime)
|
||||
{
|
||||
return app;
|
||||
}
|
||||
|
||||
RegisteredBrowserLinkModule preferredRuntime = RegistryUtil.FindPreferredBrowserLinkModule();
|
||||
|
||||
if (preferredRuntime != null)
|
||||
{
|
||||
return preferredRuntime.InvokeUseBrowserLink(app);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Bug 1192984: Browser Link couldn't be loaded for some reason, so it
|
||||
// will be disabled. Let the app continue working.
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
private static bool IsMicrosoftRuntime
|
||||
{
|
||||
get { return Type.GetType("Mono.Runtime") == null; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>c31202e6-fc58-4354-b2d2-acd1b3118c05</ProjectGuid>
|
||||
<RootNamespace>Microsoft.VisualStudio.Web.BrowserLink.Loader</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": "14.0.0-*",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Http.Abstractions": "1.0.0-*",
|
||||
"Microsoft.AspNet.FileProviders.Physical": "1.0.0-*",
|
||||
"Microsoft.Dnx.Runtime.Abstractions": "1.0.0-*",
|
||||
"Microsoft.AspNet.PageExecutionInstrumentation.Interfaces" : "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {
|
||||
"dependencies": { }
|
||||
},
|
||||
"dnxcore50": {
|
||||
"dependencies": {
|
||||
"System.Reflection.Extensions": "4.0.0-*",
|
||||
"System.Runtime.InteropServices": "4.0.20-*",
|
||||
"System.Threading": "4.0.10-*",
|
||||
"System.Net.Sockets": "4.0.10-*",
|
||||
"System.Collections": "4.0.10-*",
|
||||
"Microsoft.Win32.Registry": "4.0.0-*"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
// 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;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.Dnx.Runtime;
|
||||
|
||||
namespace Microsoft.VisualStudio.Web.BrowserLink.Loader
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents one Browser Link middleware assembly found on the machine, and
|
||||
/// provides the ability to call methods on that middleware through reflection.
|
||||
/// </summary>
|
||||
internal class RegisteredBrowserLinkModule
|
||||
{
|
||||
// Reflection information about the UseBrowserLink method
|
||||
private const string UseBrowserLinkMethodName = "UseBrowserLink";
|
||||
private static readonly Type[] UseBrowserLinkParameters = new Type[] { typeof(IApplicationBuilder) };
|
||||
|
||||
internal RegisteredBrowserLinkModule(string name, Version version, string assemblyPath, string extensionTypeName)
|
||||
{
|
||||
Name = name;
|
||||
Version = version;
|
||||
AssemblyPath = assemblyPath;
|
||||
ExtensionTypeName = extensionTypeName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A unique name identifying this module.
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The build version of this module.
|
||||
/// </summary>
|
||||
public Version Version { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The path to the assembly implementing this module.
|
||||
/// </summary>
|
||||
public string AssemblyPath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type name (including namespace) of the type that implements methods
|
||||
/// that should be invoked using reflection.
|
||||
/// </summary>
|
||||
public string ExtensionTypeName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Load the ExtensionType, and call the UseBrowserLink method on that
|
||||
/// type. This will configure Browser Link for the application.
|
||||
/// </summary>
|
||||
/// <param name="app">The application being configured.</param>
|
||||
/// <returns><paramref name="app"/></returns>
|
||||
public IApplicationBuilder InvokeUseBrowserLink(IApplicationBuilder app)
|
||||
{
|
||||
MethodInfo useBrowserLinkMethod;
|
||||
|
||||
if (GetUseBrowserLinkExtensionMethod(app, out useBrowserLinkMethod))
|
||||
{
|
||||
return (IApplicationBuilder)useBrowserLinkMethod.Invoke(null, new object[] { app });
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
private bool GetUseBrowserLinkExtensionMethod(IApplicationBuilder app, out MethodInfo useBrowserLinkMethod)
|
||||
{
|
||||
return GetExtensionMethod(app, UseBrowserLinkMethodName, UseBrowserLinkParameters, out useBrowserLinkMethod);
|
||||
}
|
||||
|
||||
private bool GetExtensionMethod(IApplicationBuilder app, string methodName, Type[] parameterTypes, out MethodInfo method)
|
||||
{
|
||||
Type extensionType;
|
||||
|
||||
if (GetExtensionType(app, out extensionType))
|
||||
{
|
||||
method = extensionType.GetRuntimeMethod(methodName, parameterTypes);
|
||||
|
||||
return method != null;
|
||||
}
|
||||
else
|
||||
{
|
||||
method = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool GetExtensionType(IApplicationBuilder app, out Type extensionType)
|
||||
{
|
||||
Assembly runtimeAssembly;
|
||||
|
||||
if (LoadRuntimeAssembly(app, out runtimeAssembly))
|
||||
{
|
||||
extensionType = runtimeAssembly.GetType(ExtensionTypeName);
|
||||
|
||||
return extensionType != null;
|
||||
}
|
||||
else
|
||||
{
|
||||
extensionType = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool LoadRuntimeAssembly(IApplicationBuilder app, out Assembly runtimeAssembly)
|
||||
{
|
||||
IAssemblyLoadContextAccessor loadContextAccessor = app.ApplicationServices.GetService(typeof(IAssemblyLoadContextAccessor)) as IAssemblyLoadContextAccessor;
|
||||
|
||||
if (loadContextAccessor != null)
|
||||
{
|
||||
IAssemblyLoadContext loadContext = loadContextAccessor.GetLoadContext(this.GetType().GetTypeInfo().Assembly);
|
||||
|
||||
if (loadContext != null)
|
||||
{
|
||||
runtimeAssembly = loadContext.LoadFile(AssemblyPath);
|
||||
|
||||
return runtimeAssembly != null;
|
||||
}
|
||||
}
|
||||
|
||||
runtimeAssembly = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Microsoft.VisualStudio.Web.BrowserLink.Loader
|
||||
{
|
||||
/// <summary>
|
||||
/// Support to look up information about Browser Link modules from the registry.
|
||||
/// Browser Link modules are registered under RegistryUtil.BrowserLinkRegistryKey
|
||||
/// as follows:
|
||||
///
|
||||
/// [HKEY_LOCAL_MACHINE\(RegistryUtil.BrowserLinkRegistryKey)\(Unique-Name-For-Module)]
|
||||
/// "dnxcore50"="Path\to\assembly\for\Core\CLR"
|
||||
/// "dnx451"="Path\to\assembly\for\Desktop\CLR"
|
||||
/// "ExtensionType"="Namespace.TypeName"
|
||||
/// "Version"="WTE Version"
|
||||
/// </summary>
|
||||
internal static class RegistryUtil
|
||||
{
|
||||
// The key, under HKLM, where Browser Link modules are registered
|
||||
private const string BrowserLinkRegistryKey = @"SOFTWARE\Microsoft\Browser Link";
|
||||
|
||||
// Names of values under each registration key
|
||||
private static readonly string VersionName = "Version";
|
||||
private static readonly string TypeName = "ExtensionType";
|
||||
|
||||
#if DNXCORE50
|
||||
private static readonly string PathName = "dnxcore50";
|
||||
#elif DNX451
|
||||
private static readonly string PathName = "dnx451";
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Return the module from the registry with the highest version number.
|
||||
/// Modules should be backward-compatible, so that the highest-version
|
||||
/// module can handle requests from all SxS installed versions of WTE.
|
||||
/// </summary>
|
||||
/// <returns>A browser link module, or null if no modules were found.</returns>
|
||||
public static RegisteredBrowserLinkModule FindPreferredBrowserLinkModule()
|
||||
{
|
||||
List<RegisteredBrowserLinkModule> runtimes = FindAllBrowserLinkModules();
|
||||
|
||||
if (runtimes.Count >= 1)
|
||||
{
|
||||
runtimes.Sort(CompareBrowserLinkModulesByVersion);
|
||||
|
||||
return runtimes[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static List<RegisteredBrowserLinkModule> FindAllBrowserLinkModules()
|
||||
{
|
||||
List<RegisteredBrowserLinkModule> runtimes = new List<RegisteredBrowserLinkModule>();
|
||||
|
||||
RegistryKey rootKey = Registry.LocalMachine.OpenSubKey(BrowserLinkRegistryKey);
|
||||
if (rootKey != null)
|
||||
{
|
||||
foreach (string subKeyName in rootKey.GetSubKeyNames())
|
||||
{
|
||||
RegistryKey subKey = rootKey.OpenSubKey(subKeyName);
|
||||
|
||||
if (subKey != null)
|
||||
{
|
||||
RegisteredBrowserLinkModule runtime = ReadModuleInformation(subKeyName, subKey);
|
||||
|
||||
if (runtime != null)
|
||||
{
|
||||
runtimes.Add(runtime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return runtimes;
|
||||
}
|
||||
|
||||
private static int CompareBrowserLinkModulesByVersion(RegisteredBrowserLinkModule x, RegisteredBrowserLinkModule y)
|
||||
{
|
||||
// Sort in reverse order of version
|
||||
return y.Version.CompareTo(x.Version);
|
||||
}
|
||||
|
||||
private static RegisteredBrowserLinkModule ReadModuleInformation(string subKeyName, RegistryKey subKey)
|
||||
{
|
||||
Version version;
|
||||
string path;
|
||||
string typeName;
|
||||
|
||||
if (TryGetVersionValue(subKey, VersionName, out version) &&
|
||||
TryGetStringValue(subKey, PathName, out path) &&
|
||||
TryGetStringValue(subKey, TypeName, out typeName))
|
||||
{
|
||||
return new RegisteredBrowserLinkModule(subKeyName, version, path, typeName);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static bool TryGetVersionValue(RegistryKey key, string name, out Version version)
|
||||
{
|
||||
string versionString;
|
||||
|
||||
if (TryGetStringValue(key, name, out versionString))
|
||||
{
|
||||
return Version.TryParse(versionString, out version);
|
||||
}
|
||||
else
|
||||
{
|
||||
version = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryGetStringValue(RegistryKey key, string name, out string value)
|
||||
{
|
||||
object untypedValue = key.GetValue(name, null);
|
||||
if (untypedValue != null &&
|
||||
key.GetValueKind(name) == RegistryValueKind.String)
|
||||
{
|
||||
value = (string)untypedValue;
|
||||
return value != null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче