提交 60ef8bc8 编写于 作者: A Ashley Hauck 提交者: GitHub

Merge pull request #22075 from khyperia/vbcscompiler_multitarget

Multitarget VBCSCompiler.csproj
......@@ -171,6 +171,7 @@
<SystemIOFileSystemPrimitivesVersion>4.3.0</SystemIOFileSystemPrimitivesVersion>
<SystemIOFileSystemWatcherVersion>4.3.0</SystemIOFileSystemWatcherVersion>
<SystemIOPipesVersion>4.3.0</SystemIOPipesVersion>
<SystemIOPipesAccessControlVersion>4.3.0</SystemIOPipesAccessControlVersion>
<SystemLinqVersion>4.3.0</SystemLinqVersion>
<SystemLinqExpressionsVersion>4.3.0</SystemLinqExpressionsVersion>
<SystemLinqParallelVersion>4.3.0</SystemLinqParallelVersion>
......
......@@ -50,7 +50,7 @@
"Dlls\\Workspaces\\Microsoft.CodeAnalysis.Workspaces.dll",
"Dlls\\XamlVisualStudio\\Microsoft.VisualStudio.LanguageServices.Xaml.dll",
"Exes\\InteractiveHost\\InteractiveHost.exe",
"Exes\\VBCSCompiler\\VBCSCompiler.exe",
"Exes\\VBCSCompiler\\net46\\VBCSCompiler.exe",
"Exes\\csc\\csc.exe",
"Exes\\csccore\\csc.dll",
"Exes\\csi\\csi.exe",
......
......@@ -102,6 +102,8 @@
<IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup</IncludeOutputGroupsInVSIX>
<IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup%3b</IncludeOutputGroupsInVSIXLocalOnly>
<ForceIncludeInVSIX>true</ForceIncludeInVSIX>
<!-- Workaround for https://github.com/dotnet/sdk/issues/433#issuecomment-320024771 . Remove once resolved. -->
<AdditionalProperties>TargetFramework=net46</AdditionalProperties>
</ProjectReference>
<ProjectReference Include="..\CSharp\csc\csc.csproj">
<IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup%3bGetCopyToOutputDirectoryItems</IncludeOutputGroupsInVSIX>
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if NETCOREAPP2_0
using System;
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.CompilerServer
{
internal sealed class CoreClrCompilerServerHost : CompilerServerHost
{
private static readonly IAnalyzerAssemblyLoader s_analyzerLoader = new CoreClrAnalyzerAssemblyLoader();
// Caches are used by C# and VB compilers, and shared here.
public static readonly Func<string, MetadataReferenceProperties, PortableExecutableReference> SharedAssemblyReferenceProvider = (path, properties) => new CachingMetadataReference(path, properties);
public override IAnalyzerAssemblyLoader AnalyzerAssemblyLoader => s_analyzerLoader;
public override Func<string, MetadataReferenceProperties, PortableExecutableReference> AssemblyReferenceProvider => SharedAssemblyReferenceProvider;
internal CoreClrCompilerServerHost(string clientDirectory, string sdkDirectory)
: base(clientDirectory, sdkDirectory)
{
}
public override bool CheckAnalyzers(string baseDirectory, ImmutableArray<CommandLineAnalyzerReference> analyzers)
{
return AnalyzerConsistencyChecker.Check(baseDirectory, analyzers, s_analyzerLoader);
}
}
}
#endif
// Copyright (c) Microsoft. 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 System.Configuration;
using System.Diagnostics;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
using System.Globalization;
......@@ -34,8 +28,13 @@ protected override IClientConnectionHost CreateClientConnectionHost(string pipeN
// VBCSCompiler is installed in the same directory as csc.exe and vbc.exe which is also the
// location of the response files.
var clientDirectory = AppDomain.CurrentDomain.BaseDirectory;
#if NET46
var sdkDirectory = RuntimeEnvironment.GetRuntimeDirectory();
var compilerServerHost = new DesktopCompilerServerHost(clientDirectory, sdkDirectory);
#else
var sdkDirectory = (string)null;
var compilerServerHost = new CoreClrCompilerServerHost(clientDirectory, sdkDirectory);
#endif
return new NamedPipeClientConnectionHost(compilerServerHost, pipeName);
}
......@@ -63,7 +62,7 @@ protected override IClientConnectionHost CreateClientConnectionHost(string pipeN
return ServerDispatcher.DefaultServerKeepAlive;
}
}
catch (ConfigurationErrorsException e)
catch (Exception e)
{
CompilerServerLogger.LogException(e, "Could not read AppSettings");
return ServerDispatcher.DefaultServerKeepAlive;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if NET46
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CommandLine;
using System.IO.Pipes;
using System.Threading;
using System.Security.Principal;
using System.Security.AccessControl;
namespace Microsoft.CodeAnalysis.CompilerServer
{
......@@ -27,11 +19,6 @@ internal sealed class DesktopCompilerServerHost : CompilerServerHost
public override Func<string, MetadataReferenceProperties, PortableExecutableReference> AssemblyReferenceProvider => SharedAssemblyReferenceProvider;
internal DesktopCompilerServerHost()
: this(AppDomain.CurrentDomain.BaseDirectory, RuntimeEnvironment.GetRuntimeDirectory())
{
}
internal DesktopCompilerServerHost(string clientDirectory, string sdkDirectory)
: base(clientDirectory, sdkDirectory)
{
......@@ -43,3 +30,5 @@ public override bool CheckAnalyzers(string baseDirectory, ImmutableArray<Command
}
}
}
#endif
......@@ -136,6 +136,7 @@ private NamedPipeServerStream ConstructPipe(string pipeName)
SecurityIdentifier identifier = WindowsIdentity.GetCurrent().Owner;
PipeSecurity security = new PipeSecurity();
#if NET46
// Restrict access to just this account.
PipeAccessRule rule = new PipeAccessRule(identifier, PipeAccessRights.ReadWrite | PipeAccessRights.CreateNewInstance, AccessControlType.Allow);
security.AddAccessRule(rule);
......@@ -151,6 +152,24 @@ private NamedPipeServerStream ConstructPipe(string pipeName)
PipeBufferSize, // Default output buffer
security,
HandleInheritability.None);
#else
// The overload of NamedPipeServerStream with the PipeAccessRule
// parameter was removed in netstandard. However, the default
// constructor does not provide WRITE_DAC, so attempting to use
// SetAccessControl will always fail. So, completely ignore ACLs on
// netcore, and trust that our `ClientAndOurIdentitiesMatch`
// verification will catch any invalid connections.
// Issue to add WRITE_DAC support:
// https://github.com/dotnet/corefx/issues/24040
NamedPipeServerStream pipeStream = new NamedPipeServerStream(
pipeName,
PipeDirection.InOut,
NamedPipeServerStream.MaxAllowedServerInstances, // Maximum connections.
PipeTransmissionMode.Byte,
PipeOptions.Asynchronous | PipeOptions.WriteThrough,
PipeBufferSize, // Default input buffer
PipeBufferSize);// Default output buffer
#endif
CompilerServerLogger.Log("Successfully constructed pipe '{0}'.", pipeName);
......
......@@ -3,7 +3,6 @@
using Microsoft.CodeAnalysis.CommandLine;
using System;
using System.Collections.Specialized;
using System.Configuration;
using System.IO;
namespace Microsoft.CodeAnalysis.CompilerServer
......@@ -15,7 +14,12 @@ public static int Main(string[] args)
NameValueCollection appSettings;
try
{
appSettings = ConfigurationManager.AppSettings;
#if NET46
appSettings = System.Configuration.ConfigurationManager.AppSettings;
#else
// Do not use AppSettings on non-desktop platforms
appSettings = new NameValueCollection();
#endif
}
catch (Exception ex)
{
......
......@@ -10,9 +10,10 @@
<OutputType>Exe</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.CompilerServer</RootNamespace>
<LargeAddressAware>true</LargeAddressAware>
<TargetFramework>net46</TargetFramework>
<TargetFrameworks>net46;netcoreapp2.0</TargetFrameworks>
<RuntimeIdentifiers>win7;ubuntu.14.04;osx.10.10</RuntimeIdentifiers>
<UseVSHostingProcess>false</UseVSHostingProcess>
<DisableImplicitFrameworkReferences>false</DisableImplicitFrameworkReferences>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\CSharp\Portable\CSharpCodeAnalysis.csproj" />
......@@ -22,9 +23,8 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" />
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<PackageReference Include="System.IO.Pipes.AccessControl" Version="$(SystemIOPipesAccessControlVersion)" Condition="'$(TargetFramework)' == 'netcoreapp2.0'" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\BuildClient.cs">
......@@ -33,6 +33,9 @@
<Compile Include="..\..\Shared\BuildServerConnection.cs">
<Link>BuildServerConnection.cs</Link>
</Compile>
<Compile Include="..\..\Shared\CoreClrAnalyzerAssemblyLoader.cs">
<Link>CoreClrAnalyzerAssemblyLoader.cs</Link>
</Compile>
<Compile Include="..\..\Shared\DesktopAnalyzerAssemblyLoader.cs">
<Link>DesktopAnalyzerAssemblyLoader.cs</Link>
</Compile>
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if NETCOREAPP1_1 || NETCOREAPP2_0
using System.Diagnostics;
using System.Reflection;
using System.Runtime.Loader;
......@@ -39,3 +41,5 @@ protected override Assembly LoadFromPathImpl(string fullPath)
}
}
}
#endif
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if NET46
using System;
using System.Reflection;
using System.Threading;
......@@ -46,3 +48,5 @@ private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs a
}
}
}
#endif
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if NET46
using System;
using System.Collections.Generic;
using System.IO;
......@@ -193,3 +195,5 @@ private string CreateUniqueDirectoryForProcess()
}
}
}
#endif
......@@ -40,8 +40,8 @@
<file src="Exes\vbc\vbc.exe" target="tools" />
<file src="Exes\vbc\vbc.exe.config" target="tools" />
<file src="Exes\vbc\vbc.rsp" target="tools" />
<file src="Exes\VBCSCompiler\VBCSCompiler.exe" target="tools" />
<file src="Exes\VBCSCompiler\VBCSCompiler.exe.config" target="tools" />
<file src="Exes\VBCSCompiler\net46\VBCSCompiler.exe" target="tools" />
<file src="Exes\VBCSCompiler\net46\VBCSCompiler.exe.config" target="tools" />
<file src="Dlls\MSBuildTask\Microsoft.Build.Tasks.CodeAnalysis.dll" target="tools" />
<file src="Dlls\MSbuildTask\Microsoft.CSharp.Core.targets" target="tools" />
<file src="Dlls\MSbuildTask\Microsoft.VisualBasic.Core.targets" target="tools" />
......
......@@ -833,7 +833,7 @@ Public Class BuildDevDivInsertionFiles
add("Exes\csc\csc.rsp")
add("Exes\vbc\vbc.exe.config")
add("Exes\vbc\vbc.rsp")
add("Exes\VBCSCompiler\VBCSCompiler.exe.config")
add("Exes\VBCSCompiler\net46\VBCSCompiler.exe.config")
add("Exes\InteractiveHost\InteractiveHost.exe.config")
add("Exes\csi\csi.rsp")
add("Vsix\Roslyn.Deployment.Full.Next\remoteSymbolSearchUpdateEngine.servicehub.service.json")
......
......@@ -7,7 +7,7 @@ vs.dependencies
vs.dependency id=Microsoft.Net.PackageGroup.4.6.1.Redist
folder InstallDir:\MSBuild\15.0\Bin\Roslyn
file source=$(OutputPath)\Exes\VBCSCompiler\VBCSCompiler.exe vs.file.ngenArchitecture=all
file source=$(OutputPath)\Exes\VBCSCompiler\net46\VBCSCompiler.exe vs.file.ngenArchitecture=all
file source=$(OutputPath)\Exes\csc\csc.exe vs.file.ngenArchitecture=all
file source=$(OutputPath)\Exes\csi\csi.exe vs.file.ngenArchitecture=all
file source=$(OutputPath)\Exes\vbc\vbc.exe vs.file.ngenArchitecture=all
......@@ -15,7 +15,7 @@ folder InstallDir:\MSBuild\15.0\Bin\Roslyn
file source=$(OutputPath)\Exes\csc\csc.exe.config
file source=$(OutputPath)\Exes\csi\csi.exe.config
file source=$(OutputPath)\Exes\vbc\vbc.exe.config
file source=$(OutputPath)\Exes\VBCSCompiler\VBCSCompiler.exe.config
file source=$(OutputPath)\Exes\VBCSCompiler\net46\VBCSCompiler.exe.config
file source=$(OutputPath)\Exes\csc\csc.rsp
file source=$(OutputPath)\Exes\csi\csi.rsp
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册