提交 f60facc9 编写于 作者: J Jared Parsons 提交者: GitHub

Merge pull request #14781 from jaredpar/fix-task

Make Microsoft.Build.Tasks.CodeAnalysis an independent DLL
......@@ -933,26 +933,20 @@ Global
{CCBD3438-3E84-40A9-83AD-533F23BCFCA5}.Release|x64.Build.0 = Release|x64
{CCBD3438-3E84-40A9-83AD-533F23BCFCA5}.Release|x86.ActiveCfg = Release|Any CPU
{CCBD3438-3E84-40A9-83AD-533F23BCFCA5}.Release|x86.Build.0 = Release|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|ARM.ActiveCfg = Debug|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|ARM.Build.0 = Debug|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|x64.ActiveCfg = Debug|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|x64.Build.0 = Debug|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|x86.ActiveCfg = Debug|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|x86.Build.0 = Debug|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|Any CPU.Build.0 = Release|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|ARM.ActiveCfg = Release|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|ARM.Build.0 = Release|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|x64.ActiveCfg = Release|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|x64.Build.0 = Release|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|x86.ActiveCfg = Release|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|x86.Build.0 = Release|Any CPU
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|Any CPU.ActiveCfg = Debug|x64
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|ARM.ActiveCfg = Debug|x64
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|Mixed Platforms.ActiveCfg = Debug|x64
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|Mixed Platforms.Build.0 = Debug|x64
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|x64.ActiveCfg = Debug|x64
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|x64.Build.0 = Debug|x64
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Debug|x86.ActiveCfg = Debug|x64
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|Any CPU.ActiveCfg = Release|x64
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|ARM.ActiveCfg = Release|x64
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|Mixed Platforms.ActiveCfg = Release|x64
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|Mixed Platforms.Build.0 = Release|x64
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|x64.ActiveCfg = Release|x64
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|x64.Build.0 = Release|x64
{6DA08F12-32F2-4DD9-BBAD-982EB71A2C9B}.Release|x86.ActiveCfg = Release|x64
{1B665337-9D6A-451A-AEAC-F7BF1AF95FFB}.Debug|Any CPU.ActiveCfg = Debug|x64
{1B665337-9D6A-451A-AEAC-F7BF1AF95FFB}.Debug|ARM.ActiveCfg = Debug|x64
{1B665337-9D6A-451A-AEAC-F7BF1AF95FFB}.Debug|Mixed Platforms.ActiveCfg = Debug|x64
......
......@@ -44,6 +44,9 @@
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\Shared\BuildClient.cs">
<Link>BuildClient.cs</Link>
</Compile>
<Compile Include="..\..\Shared\CoreClrAnalyzerAssemblyLoader.cs">
<Link>CoreClrAnalyzerAssemblyLoader.cs</Link>
</Compile>
......@@ -69,4 +72,4 @@
</ItemGroup>
<Import Project="..\..\Core\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</Project>
</Project>
\ No newline at end of file
......@@ -1207,7 +1207,7 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
}
}
var parsedFeatures = CompilerOptionParseUtilities.ParseFeatures(features);
var parsedFeatures = ParseFeatures(features);
string compilationName;
GetCompilationAndModuleNames(diagnostics, outputKind, sourceFiles, sourceFilesSpecified, moduleAssemblyName, ref outputFileName, ref moduleName, out compilationName);
......
......@@ -2,6 +2,7 @@
using System.Diagnostics;
using System.Globalization;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp
{
......
......@@ -35,6 +35,12 @@
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\BuildClient.cs">
<Link>BuildClient.cs</Link>
</Compile>
<Compile Include="..\..\Shared\BuildServerConnection.cs">
<Link>BuildServerConnection.cs</Link>
</Compile>
<Compile Include="..\..\Shared\DesktopBuildClient.cs">
<Link>DesktopBuildClient.cs</Link>
</Compile>
......@@ -61,4 +67,4 @@
</ItemGroup>
<Import Project="..\..\Core\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</Project>
</Project>
\ No newline at end of file
......@@ -3,7 +3,7 @@
using Roslyn.Utilities;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Reflection;
......@@ -42,22 +42,22 @@ internal class BuildRequest
{
public readonly uint ProtocolVersion;
public readonly RequestLanguage Language;
public readonly ImmutableArray<Argument> Arguments;
public readonly ReadOnlyCollection<Argument> Arguments;
public BuildRequest(uint protocolVersion,
RequestLanguage language,
ImmutableArray<Argument> arguments)
IEnumerable<Argument> arguments)
{
ProtocolVersion = protocolVersion;
Language = language;
Arguments = new ReadOnlyCollection<Argument>(arguments.ToList());
if (arguments.Length > ushort.MaxValue)
if (Arguments.Count > ushort.MaxValue)
{
throw new ArgumentOutOfRangeException(nameof(arguments),
"Too many arguments: maximum of "
+ ushort.MaxValue + " arguments allowed.");
}
Arguments = arguments;
}
public static BuildRequest Create(RequestLanguage language,
......@@ -73,7 +73,7 @@ internal class BuildRequest
Log($"Lib directory: {libDirectory ?? "null"}");
var requestLength = args.Count + 1 + (libDirectory == null ? 0 : 1);
var requestArgs = ImmutableArray.CreateBuilder<Argument>(requestLength);
var requestArgs = new List<Argument>(requestLength);
requestArgs.Add(new Argument(ArgumentId.CurrentDirectory, 0, workingDirectory));
requestArgs.Add(new Argument(ArgumentId.TempDirectory, 0, tempDirectory));
......@@ -95,12 +95,12 @@ internal class BuildRequest
requestArgs.Add(new Argument(ArgumentId.CommandLineArgument, i, arg));
}
return new BuildRequest(BuildProtocolConstants.ProtocolVersion, language, requestArgs.ToImmutable());
return new BuildRequest(BuildProtocolConstants.ProtocolVersion, language, requestArgs);
}
public static BuildRequest CreateShutdown()
{
var requestArgs = ImmutableArray.Create(new Argument(ArgumentId.Shutdown, argumentIndex: 0, value: ""));
var requestArgs = new[] { new Argument(ArgumentId.Shutdown, argumentIndex: 0, value: "") };
return new BuildRequest(BuildProtocolConstants.ProtocolVersion, RequestLanguage.CSharpCompile, requestArgs);
}
......@@ -141,7 +141,7 @@ public static async Task<BuildRequest> ReadAsync(Stream inStream, CancellationTo
var language = (RequestLanguage)reader.ReadUInt32();
uint argumentCount = reader.ReadUInt32();
var argumentsBuilder = ImmutableArray.CreateBuilder<Argument>((int)argumentCount);
var argumentsBuilder = new List<Argument>((int)argumentCount);
for (int i = 0; i < argumentCount; i++)
{
......@@ -151,7 +151,7 @@ public static async Task<BuildRequest> ReadAsync(Stream inStream, CancellationTo
return new BuildRequest(protocolVersion,
language,
argumentsBuilder.ToImmutableArray());
argumentsBuilder);
}
}
......@@ -167,7 +167,7 @@ public async Task WriteAsync(Stream outStream, CancellationToken cancellationTok
Log("Formatting request");
writer.Write(ProtocolVersion);
writer.Write((uint)Language);
writer.Write(Arguments.Length);
writer.Write(Arguments.Count);
foreach (Argument arg in Arguments)
{
cancellationToken.ThrowIfCancellationRequested();
......
......@@ -10,7 +10,6 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)BuildProtocol.cs" />
<Compile Include="$(MSBuildThisFileDirectory)BuildClient.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConsoleUtil.cs" />
<Compile Include="$(MSBuildThisFileDirectory)NativeMethods.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CompilerServerLogger.cs" />
......
......@@ -4,12 +4,11 @@
using System.Diagnostics;
using System.Globalization;
using System.Text;
using Roslyn.Utilities;
using Microsoft.Build.Framework;
using Microsoft.Build.Tasks.Hosting;
using Microsoft.Build.Utilities;
using Microsoft.CodeAnalysis.CommandLine;
using Microsoft.CodeAnalysis.CSharp;
namespace Microsoft.CodeAnalysis.BuildTasks
{
......@@ -154,8 +153,6 @@ public string WarningsNotAsErrors
#region Tool Members
internal override RequestLanguage Language => RequestLanguage.CSharpCompile;
private static readonly string[] s_separators = { "\r\n" };
internal override void LogMessages(string output, MessageImportance messageImportance)
......@@ -281,6 +278,8 @@ protected internal override void AddResponseFileCommands(CommandLineBuilderExten
#endregion
internal override RequestLanguage Language => RequestLanguage.CSharpCompile;
/// <summary>
/// The C# compiler (starting with Whidbey) supports assembly aliasing for references.
/// See spec at http://devdiv/spectool/Documents/Whidbey/VCSharp/Design%20Time/M3%20DCRs/DCR%20Assembly%20aliases.doc.
......@@ -412,7 +411,7 @@ internal static string GetDefineConstantsSwitch(string originalDefineConstants,
// add them to the outgoing string.
foreach (string singleIdentifier in allIdentifiers)
{
if (SyntaxFacts.IsValidIdentifier(singleIdentifier))
if (UnicodeCharacterUtilities.IsValidIdentifier(singleIdentifier))
{
// Separate them with a semicolon if there's something already in
// the outgoing string.
......
......@@ -2,9 +2,7 @@
using System;
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.CodeAnalysis.CSharp;
namespace Microsoft.CodeAnalysis.BuildTasks
{
......
// 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;
using System.Linq;
using Roslyn.Utilities;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.BuildTasks
{
......@@ -281,8 +279,8 @@ protected virtual void AddResponseFileCommands(CommandLineBuilderExtension comma
/// </summary>
private string[] GetArguments(string commandLineCommands, string responseFileCommands)
{
var commandLineArguments = CommandLineParser.SplitCommandLineIntoArguments(commandLineCommands, removeHashComments: true);
var responseFileArguments = CommandLineParser.SplitCommandLineIntoArguments(responseFileCommands, removeHashComments: true);
var commandLineArguments = CommandLineUtilities.SplitCommandLineIntoArguments(commandLineCommands, removeHashComments: true);
var responseFileArguments = CommandLineUtilities.SplitCommandLineIntoArguments(responseFileCommands, removeHashComments: true);
return commandLineArguments.Concat(responseFileArguments).ToArray();
}
}
......
......@@ -31,18 +31,20 @@
<!-- A reference to the entire .NET Framework is automatically included -->
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CSharp\Portable\CSharpCodeAnalysis.csproj">
<Project>{b501a547-c911-4a05-ac6e-274a50dff30e}</Project>
<Name>CSharpCodeAnalysis</Name>
</ProjectReference>
<ProjectReference Include="..\Portable\CodeAnalysis.csproj">
<Project>{1ee8cad3-55f9-4d91-96b2-084641da9a6c}</Project>
<Name>CodeAnalysis</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\DesktopBuildClient.cs">
<Link>DesktopBuildClient.cs</Link>
<Compile Include="..\..\Shared\BuildServerConnection.cs">
<Link>BuildServerConnection.cs</Link>
</Compile>
<Compile Include="..\Portable\InternalUtilities\CommandLineUtilities.cs">
<Link>CommandLineUtilities.cs</Link>
</Compile>
<Compile Include="..\Portable\InternalUtilities\CompilerOptionParseUtilities.cs">
<Link>CompilerOptionParseUtilities.cs</Link>
</Compile>
<Compile Include="..\Portable\InternalUtilities\IReadOnlySet.cs">
<Link>IReadOnlySet.cs</Link>
</Compile>
<Compile Include="..\Portable\InternalUtilities\UnicodeCharacterUtilities.cs">
<Link>UnicodeCharacterUtilities.cs</Link>
</Compile>
<Compile Include="CanonicalError.cs" />
<Compile Include="ValidateBootstrap.cs" />
......@@ -72,4 +74,4 @@
</ItemGroup>
<Import Project="..\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</Project>
</Project>
\ No newline at end of file
// 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.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using Roslyn.Utilities;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Roslyn.Utilities;
using Microsoft.CodeAnalysis.CommandLine;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace Microsoft.CodeAnalysis.BuildTasks
{
......@@ -25,6 +24,8 @@ public abstract class ManagedCompiler : ToolTask
private CancellationTokenSource _sharedCompileCts;
internal readonly PropertyDictionary _store = new PropertyDictionary();
internal abstract RequestLanguage Language { get; }
public ManagedCompiler()
{
TaskResources = ErrorString.ResourceManager;
......@@ -378,8 +379,6 @@ protected override Encoding StandardOutputEncoding
#endregion
internal abstract RequestLanguage Language { get; }
protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands)
{
if (ProvideCommandLineArgs)
......@@ -395,7 +394,7 @@ protected override int ExecuteTool(string pathToTool, string responseFileCommand
if (!UseSharedCompilation ||
!string.IsNullOrEmpty(ToolPath) ||
!Utilities.IsCompilerServerSupported)
!BuildServerConnection.IsCompilerServerSupported)
{
return base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
}
......@@ -419,14 +418,14 @@ protected override int ExecuteTool(string pathToTool, string responseFileCommand
Log.LogMessage(ErrorString.UsingSharedCompilation, clientDir);
var workingDir = CurrentDirectoryToUse();
var buildPaths = new BuildPaths(
var buildPaths = new BuildPathsAlt(
clientDir: clientDir,
// MSBuild doesn't need the .NET SDK directory
sdkDir: null,
workingDir: workingDir,
tempDir: BuildClient.GetTempPath(workingDir));
tempDir: BuildServerConnection.GetTempPath(workingDir));
var responseTask = DesktopBuildClient.RunServerCompilation(
var responseTask = BuildServerConnection.RunServerCompilation(
Language,
GetArguments(commandLineCommands, responseFileCommands).ToList(),
buildPaths,
......@@ -459,11 +458,10 @@ protected override int ExecuteTool(string pathToTool, string responseFileCommand
ExitCode = -1;
}
}
return ExitCode;
}
/// <summary>
/// Try to get the directory this assembly is in. Returns null if assembly
/// was in the GAC or DLL location can not be retrieved.
......@@ -582,10 +580,6 @@ private int HandleResponse(BuildResponse response, string pathToTool, string res
{
switch (response.Type)
{
case BuildResponse.ResponseType.MismatchedVersion:
LogErrorOutput(CommandLineParser.MismatchedVersionErrorText);
return -1;
case BuildResponse.ResponseType.Completed:
var completedResponse = (CompletedBuildResponse)response;
LogMessages(completedResponse.Output, StandardOutputImportanceToUse);
......@@ -601,12 +595,17 @@ private int HandleResponse(BuildResponse response, string pathToTool, string res
return completedResponse.ReturnCode;
case BuildResponse.ResponseType.MismatchedVersion:
LogErrorOutput("Roslyn compiler server reports different protocol version than build task.");
return base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
case BuildResponse.ResponseType.Rejected:
case BuildResponse.ResponseType.AnalyzerInconsistency:
return base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
default:
throw new InvalidOperationException("Encountered unknown response type");
LogErrorOutput($"Recieved an unrecognized response from the server: {response.Type}");
return base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
}
}
......@@ -643,9 +642,9 @@ public string GenerateResponseFileContents()
private string[] GetArguments(string commandLineCommands, string responseFileCommands)
{
var commandLineArguments =
CommandLineParser.SplitCommandLineIntoArguments(commandLineCommands, removeHashComments: true);
CommandLineUtilities.SplitCommandLineIntoArguments(commandLineCommands, removeHashComments: true);
var responseFileArguments =
CommandLineParser.SplitCommandLineIntoArguments(responseFileCommands, removeHashComments: true);
CommandLineUtilities.SplitCommandLineIntoArguments(responseFileCommands, removeHashComments: true);
return commandLineArguments.Concat(responseFileArguments).ToArray();
}
......
......@@ -5,7 +5,6 @@
using System.IO;
using System.Security;
using Microsoft.Build.Framework;
using Microsoft.CodeAnalysis.CommandLine;
using System.Runtime.InteropServices;
using System.Reflection;
......@@ -16,15 +15,6 @@ namespace Microsoft.CodeAnalysis.BuildTasks
/// </summary>
internal static class Utilities
{
/// <summary>
/// False if the compiler server is not supported on this platform.
/// </summary>
internal static bool IsCompilerServerSupported =>
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
DesktopBuildClient.GetRuntimeDirectoryOpt() != null &&
// Test that we can retrieve a valid pipe name
DesktopBuildClient.GetPipeNameForPathOpt("") != null;
/// <summary>
/// Convert a task item metadata to bool. Throw an exception if the string is badly formed and can't
/// be converted.
......
......@@ -3,7 +3,6 @@
using Microsoft.Build.Utilities;
using System.IO;
using System.Reflection;
using Microsoft.CodeAnalysis.CSharp;
using System;
namespace Microsoft.CodeAnalysis.BuildTasks
......@@ -40,8 +39,6 @@ public override bool Execute()
var dependencies = new[]
{
typeof(ValidateBootstrap).GetTypeInfo().Assembly,
typeof(CSharpCompilation).GetTypeInfo().Assembly,
typeof(Compilation).GetTypeInfo().Assembly,
};
var allGood = true;
......
// 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.Diagnostics;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Build.Tasks.Hosting;
using Microsoft.CodeAnalysis.CommandLine;
using System.Diagnostics;
namespace Microsoft.CodeAnalysis.BuildTasks
{
......@@ -36,6 +35,8 @@ public class Vbc : ManagedCompiler
private bool _isDoneOutputtingErrorMessage;
private int _numberOfLinesInErrorMessage;
internal override RequestLanguage Language => RequestLanguage.VisualBasicCompile;
#region Properties
// Please keep these alphabetized. These are the parameters specific to Vbc. The
......@@ -232,8 +233,6 @@ public string PdbFile
#region Tool Members
internal override RequestLanguage Language => RequestLanguage.VisualBasicCompile;
private static readonly string[] s_separator = { "\r\n" };
internal override void LogMessages(string output, MessageImportance messageImportance)
......
......@@ -12,11 +12,14 @@
"System.IO.FileSystem": "4.0.1",
"System.IO.FileSystem.DriveInfo": "4.0.0",
"System.IO.Pipes": "4.0.0",
"System.Linq": "4.1.0",
"System.Reflection": "4.1.0",
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0",
"System.Security.AccessControl": "4.0.0",
"System.Security.Cryptography.Algorithms": "4.2.0",
"System.Security.Principal.Windows": "4.0.0",
"System.Text.Encoding": "4.0.11",
"System.Text.Encoding.Extensions": "4.0.11",
"System.Text.RegularExpressions": "4.1.0",
"System.Threading.Thread": "4.0.0"
},
......
......@@ -23,6 +23,10 @@
<Project>{76C6F005-C89D-4348-BB4A-391898DBEB52}</Project>
<Name>TestUtilities.Desktop</Name>
</ProjectReference>
<ProjectReference Include="..\..\CSharp\Portable\CSharpCodeAnalysis.csproj">
<Project>{b501a547-c911-4a05-ac6e-274a50dff30e}</Project>
<Name>CSharpCodeAnalysis</Name>
</ProjectReference>
<ProjectReference Include="..\..\Test\Resources\Core\CompilerTestResources.csproj">
<Project>{7FE6B002-89D8-4298-9B1B-0B5C247DD1FD}</Project>
<Name>CompilerTestResources</Name>
......@@ -72,6 +76,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MiscTests.cs" />
<Compile Include="CscTests.cs" />
<Compile Include="CsiTests.cs" />
<Compile Include="IntegrationTests.cs" />
......@@ -86,4 +91,4 @@
</ItemGroup>
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
<Import Project="..\..\..\..\build\Targets\Roslyn.Toolsets.Xunit.targets" />
</Project>
</Project>
\ No newline at end of file
// 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.Linq;
using Microsoft.Build.Framework;
using Microsoft.CodeAnalysis.BuildTasks;
using Xunit;
using Moq;
using Roslyn.Test.Utilities;
using Microsoft.CodeAnalysis.CSharp;
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.BuildTasks.UnitTests
{
public sealed class MiscTests
{
/// <summary>
/// The build task very deliberately does not depend on any of our shipping binaries. This is to avoid
/// potential load conflicts for dependencies when loading custom versions of our task.
/// </summary>
[Fact]
[WorkItem(1183, "https://github.com/Microsoft/msbuild/issues/1183")]
public void EnsureDependencies()
{
var assembly = typeof(ManagedCompiler).Assembly;
foreach (var name in assembly.GetReferencedAssemblies())
{
var isBadRef =
name.Name == typeof(Compilation).Assembly.GetName().Name ||
name.Name == typeof(CSharpCompilation).Assembly.GetName().Name ||
name.Name == typeof(ImmutableArray<string>).Assembly.GetName().Name;
Assert.False(isBadRef);
}
}
}
}
......@@ -2,6 +2,7 @@
"dependencies": {
"xunit": "2.1.0",
"xunit.runner.console": "2.2.0-beta1-build3239",
"System.Collections.Immutable": "1.2.0",
"Roslyn.Microsoft.Build": "0.0.2",
"Moq": "4.2.1402.2112"
},
......
......@@ -44,6 +44,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
<Compile Include="InternalUtilities\CommandLineUtilities.cs" />
<Compile Include="Syntax\InternalSyntax\GreenNodeExtensions.cs" />
<Compile Include="Syntax\InternalSyntax\SyntaxListPool.cs" />
<Compile Include="Syntax\SyntaxList.SeparatedWithManyWeakChildren.cs" />
......@@ -143,7 +144,7 @@
<Compile Include="Text\SourceTextComparer.cs" />
<Compile Include="Text\SourceTextWriter.cs" />
<Compile Include="Text\StringTextWriter.cs" />
<Compile Include="UnicodeCharacterUtilities.cs" />
<Compile Include="InternalUtilities\UnicodeCharacterUtilities.cs" />
<Compile Include="CodeAnalysisResources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
......@@ -813,4 +814,4 @@
<Import Project="..\..\..\Dependencies\CodeAnalysis.Metadata\Microsoft.CodeAnalysis.Metadata.projitems" Label="Shared" />
<Import Project="..\..\..\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems" Label="Shared" />
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</Project>
</Project>
\ No newline at end of file
......@@ -621,145 +621,11 @@ internal static IEnumerable<string> ParseResponseLines(IEnumerable<string> lines
}
/// <summary>
/// Split a command line by the same rules as Main would get the commands except the original
/// state of backslashes and quotes are preserved. For example in normal Windows command line
/// parsing the following command lines would produce equivalent Main arguments:
///
/// - /r:a,b
/// - /r:"a,b"
///
/// This method will differ as the latter will have the quotes preserved. The only case where
/// quotes are removed is when the entire argument is surrounded by quotes without any inner
/// quotes.
/// See <see cref="CommandLineUtilities.SplitCommandLineIntoArguments(string, bool)"/>
/// </summary>
/// <remarks>
/// Rules for command line parsing, according to MSDN:
///
/// Arguments are delimited by white space, which is either a space or a tab.
///
/// A string surrounded by double quotation marks ("string") is interpreted
/// as a single argument, regardless of white space contained within.
/// A quoted string can be embedded in an argument.
///
/// A double quotation mark preceded by a backslash (\") is interpreted as a
/// literal double quotation mark character (").
///
/// Backslashes are interpreted literally, unless they immediately precede a
/// double quotation mark.
///
/// If an even number of backslashes is followed by a double quotation mark,
/// one backslash is placed in the argv array for every pair of backslashes,
/// and the double quotation mark is interpreted as a string delimiter.
///
/// If an odd number of backslashes is followed by a double quotation mark,
/// one backslash is placed in the argv array for every pair of backslashes,
/// and the double quotation mark is "escaped" by the remaining backslash,
/// causing a literal double quotation mark (") to be placed in argv.
/// </remarks>
public static IEnumerable<string> SplitCommandLineIntoArguments(string commandLine, bool removeHashComments)
{
char? unused;
return SplitCommandLineIntoArguments(commandLine, removeHashComments, out unused);
}
private static IEnumerable<string> SplitCommandLineIntoArguments(string commandLine, bool removeHashComments, out char? illegalChar)
{
var builder = new StringBuilder(commandLine.Length);
var list = new List<string>();
var i = 0;
illegalChar = null;
while (i < commandLine.Length)
{
while (i < commandLine.Length && char.IsWhiteSpace(commandLine[i]))
{
i++;
}
if (i == commandLine.Length)
{
break;
}
if (commandLine[i] == '#' && removeHashComments)
{
break;
}
var quoteCount = 0;
builder.Length = 0;
while (i < commandLine.Length && (!char.IsWhiteSpace(commandLine[i]) || (quoteCount % 2 != 0)))
{
var current = commandLine[i];
switch (current)
{
case '\\':
{
var slashCount = 0;
do
{
builder.Append(commandLine[i]);
i++;
slashCount++;
} while (i < commandLine.Length && commandLine[i] == '\\');
// Slashes not followed by a quote character can be ignored for now
if (i >= commandLine.Length || commandLine[i] != '"')
{
break;
}
// If there is an odd number of slashes then it is escaping the quote
// otherwise it is just a quote.
if (slashCount % 2 == 0)
{
quoteCount++;
}
builder.Append('"');
i++;
break;
}
case '"':
builder.Append(current);
quoteCount++;
i++;
break;
default:
if ((current >= 0x1 && current <= 0x1f) || current == '|')
{
if (illegalChar == null)
{
illegalChar = current;
}
}
else
{
builder.Append(current);
}
i++;
break;
}
}
// If the quote string is surrounded by quotes with no interior quotes then
// remove the quotes here.
if (quoteCount == 2 && builder[0] == '"' && builder[builder.Length - 1] == '"')
{
builder.Remove(0, length: 1);
builder.Remove(builder.Length - 1, length: 1);
}
if (builder.Length > 0)
{
list.Add(builder.ToString());
}
}
return list;
return CommandLineUtilities.SplitCommandLineIntoArguments(commandLine, removeHashComments);
}
/// <summary>
......@@ -1194,5 +1060,12 @@ internal static bool TryParseUInt16(string value, out ushort result)
return true;
}
internal static ImmutableDictionary<string, string> ParseFeatures(List<string> features)
{
var builder = ImmutableDictionary.CreateBuilder<string, string>();
CompilerOptionParseUtilities.ParseFeatures(builder, features);
return builder.ToImmutable();
}
}
}
......@@ -5,6 +5,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Diagnostics
{
......
// 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.Collections.Generic;
using System.Text;
namespace Roslyn.Utilities
{
internal static class CommandLineUtilities
{
/// <summary>
/// Split a command line by the same rules as Main would get the commands except the original
/// state of backslashes and quotes are preserved. For example in normal Windows command line
/// parsing the following command lines would produce equivalent Main arguments:
///
/// - /r:a,b
/// - /r:"a,b"
///
/// This method will differ as the latter will have the quotes preserved. The only case where
/// quotes are removed is when the entire argument is surrounded by quotes without any inner
/// quotes.
/// </summary>
/// <remarks>
/// Rules for command line parsing, according to MSDN:
///
/// Arguments are delimited by white space, which is either a space or a tab.
///
/// A string surrounded by double quotation marks ("string") is interpreted
/// as a single argument, regardless of white space contained within.
/// A quoted string can be embedded in an argument.
///
/// A double quotation mark preceded by a backslash (\") is interpreted as a
/// literal double quotation mark character (").
///
/// Backslashes are interpreted literally, unless they immediately precede a
/// double quotation mark.
///
/// If an even number of backslashes is followed by a double quotation mark,
/// one backslash is placed in the argv array for every pair of backslashes,
/// and the double quotation mark is interpreted as a string delimiter.
///
/// If an odd number of backslashes is followed by a double quotation mark,
/// one backslash is placed in the argv array for every pair of backslashes,
/// and the double quotation mark is "escaped" by the remaining backslash,
/// causing a literal double quotation mark (") to be placed in argv.
/// </remarks>
public static IEnumerable<string> SplitCommandLineIntoArguments(string commandLine, bool removeHashComments)
{
char? unused;
return SplitCommandLineIntoArguments(commandLine, removeHashComments, out unused);
}
public static IEnumerable<string> SplitCommandLineIntoArguments(string commandLine, bool removeHashComments, out char? illegalChar)
{
var builder = new StringBuilder(commandLine.Length);
var list = new List<string>();
var i = 0;
illegalChar = null;
while (i < commandLine.Length)
{
while (i < commandLine.Length && char.IsWhiteSpace(commandLine[i]))
{
i++;
}
if (i == commandLine.Length)
{
break;
}
if (commandLine[i] == '#' && removeHashComments)
{
break;
}
var quoteCount = 0;
builder.Length = 0;
while (i < commandLine.Length && (!char.IsWhiteSpace(commandLine[i]) || (quoteCount % 2 != 0)))
{
var current = commandLine[i];
switch (current)
{
case '\\':
{
var slashCount = 0;
do
{
builder.Append(commandLine[i]);
i++;
slashCount++;
} while (i < commandLine.Length && commandLine[i] == '\\');
// Slashes not followed by a quote character can be ignored for now
if (i >= commandLine.Length || commandLine[i] != '"')
{
break;
}
// If there is an odd number of slashes then it is escaping the quote
// otherwise it is just a quote.
if (slashCount % 2 == 0)
{
quoteCount++;
}
builder.Append('"');
i++;
break;
}
case '"':
builder.Append(current);
quoteCount++;
i++;
break;
default:
if ((current >= 0x1 && current <= 0x1f) || current == '|')
{
if (illegalChar == null)
{
illegalChar = current;
}
}
else
{
builder.Append(current);
}
i++;
break;
}
}
// If the quote string is surrounded by quotes with no interior quotes then
// remove the quotes here.
if (quoteCount == 2 && builder[0] == '"' && builder[builder.Length - 1] == '"')
{
builder.Remove(0, length: 1);
builder.Remove(builder.Length - 1, length: 1);
}
if (builder.Length > 0)
{
list.Add(builder.ToString());
}
}
return list;
}
}
}
......@@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
namespace Roslyn.Utilities
{
......@@ -16,16 +15,14 @@ public static IList<string> ParseFeatureFromMSBuild(string features)
{
if (string.IsNullOrEmpty(features))
{
return SpecializedCollections.EmptyList<string>();
return new List<string>(capacity: 0);
}
return features.Split(new[] { ';', ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
}
public static ImmutableDictionary<string, string> ParseFeatures(List<string> values)
public static void ParseFeatures(IDictionary<string, string> builder, List<string> values)
{
var builder = ImmutableDictionary.CreateBuilder<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (var commaFeatures in values)
{
foreach (var feature in commaFeatures.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
......@@ -33,21 +30,9 @@ public static IList<string> ParseFeatureFromMSBuild(string features)
ParseFeatureCore(builder, feature);
}
}
return builder.ToImmutable();
}
public static ImmutableDictionary<string, string> ParseFeatures(string features)
{
var builder = ImmutableDictionary.CreateBuilder<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (var feature in ParseFeatureFromMSBuild(features))
{
ParseFeatureCore(builder, feature);
}
return builder.ToImmutable();
}
private static void ParseFeatureCore(ImmutableDictionary<string, string>.Builder builder, string feature)
private static void ParseFeatureCore(IDictionary<string, string> builder, string feature)
{
int equals = feature.IndexOf('=');
if (equals > 0)
......
......@@ -2,7 +2,7 @@
using System.Globalization;
namespace Microsoft.CodeAnalysis
namespace Roslyn.Utilities
{
/// <summary>
/// Defines a set of helper methods to classify Unicode characters.
......
......@@ -207,7 +207,7 @@ private async Task<ConnectionData> HandleShutdownRequest(CancellationToken cance
private bool IsShutdownRequest(BuildRequest request)
{
return request.Arguments.Length == 1 && request.Arguments[0].ArgumentId == BuildProtocolConstants.ArgumentId.Shutdown;
return request.Arguments.Count == 1 && request.Arguments[0].ArgumentId == BuildProtocolConstants.ArgumentId.Shutdown;
}
protected virtual Task<BuildResponse> ServeBuildRequest(BuildRequest buildRequest, CancellationToken cancellationToken)
......
......@@ -80,13 +80,13 @@ protected override Task<Stream> ConnectForShutdownAsync(string pipeName, int tim
protected override string GetDefaultPipeName()
{
var clientDirectory = AppDomain.CurrentDomain.BaseDirectory;
return DesktopBuildClient.GetPipeNameForPathOpt(clientDirectory);
return BuildServerConnection.GetPipeNameForPathOpt(clientDirectory);
}
protected override bool? WasServerRunning(string pipeName)
{
string mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
return DesktopBuildClient.WasServerMutexOpen(mutexName);
string mutexName = BuildServerConnection.GetServerMutexName(pipeName);
return BuildServerConnection.WasServerMutexOpen(mutexName);
}
protected override int RunServerCore(string pipeName, IClientConnectionHost connectionHost, IDiagnosticListener listener, TimeSpan? keepAlive, CancellationToken cancellationToken)
......@@ -94,7 +94,7 @@ protected override int RunServerCore(string pipeName, IClientConnectionHost conn
// Grab the server mutex to prevent multiple servers from starting with the same
// pipename and consuming excess resources. If someone else holds the mutex
// exit immediately with a non-zero exit code
var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
bool holdsMutex;
using (var serverMutex = new Mutex(initiallyOwned: true,
name: mutexName,
......
......@@ -45,6 +45,12 @@
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\BuildClient.cs">
<Link>BuildClient.cs</Link>
</Compile>
<Compile Include="..\..\Shared\BuildServerConnection.cs">
<Link>BuildServerConnection.cs</Link>
</Compile>
<Compile Include="..\..\Shared\DesktopAnalyzerAssemblyLoader.cs">
<Link>DesktopAnalyzerAssemblyLoader.cs</Link>
</Compile>
......@@ -77,4 +83,4 @@
<Import Project="..\..\Core\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="..\ServerShared\ServerShared.projitems" Label="Shared" />
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</Project>
</Project>
\ No newline at end of file
......@@ -14,7 +14,7 @@ public class BuildProtocolTest : TestBase
{
private void VerifyShutdownRequest(BuildRequest request)
{
Assert.Equal(1, request.Arguments.Length);
Assert.Equal(1, request.Arguments.Count);
var argument = request.Arguments[0];
Assert.Equal(BuildProtocolConstants.ArgumentId.Shutdown, argument.ArgumentId);
......@@ -53,7 +53,7 @@ public async Task ReadWriteRequest()
var read = await BuildRequest.ReadAsync(memoryStream, default(CancellationToken));
Assert.Equal(BuildProtocolConstants.ProtocolVersion, read.ProtocolVersion);
Assert.Equal(RequestLanguage.VisualBasicCompile, read.Language);
Assert.Equal(2, read.Arguments.Length);
Assert.Equal(2, read.Arguments.Count);
Assert.Equal(BuildProtocolConstants.ArgumentId.CurrentDirectory, read.Arguments[0].ArgumentId);
Assert.Equal(0, read.Arguments[0].ArgumentIndex);
Assert.Equal("directory", read.Arguments[0].Value);
......@@ -67,7 +67,7 @@ public void ShutdownMessage()
{
var request = BuildRequest.CreateShutdown();
VerifyShutdownRequest(request);
Assert.Equal(1, request.Arguments.Length);
Assert.Equal(1, request.Arguments.Count);
var argument = request.Arguments[0];
Assert.Equal(BuildProtocolConstants.ArgumentId.Shutdown, argument.ArgumentId);
......
......@@ -301,7 +301,7 @@ public void ClientExceptionShouldBeginShutdown()
public void MutexStopsServerStarting()
{
var pipeName = Guid.NewGuid().ToString("N");
var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
bool holdsMutex;
using (var mutex = new Mutex(initiallyOwned: true,
......@@ -326,7 +326,7 @@ public void MutexStopsServerStarting()
public void MutexAcquiredWhenRunningServer()
{
var pipeName = Guid.NewGuid().ToString("N");
var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
var host = new Mock<IClientConnectionHost>(MockBehavior.Strict);
host
.Setup(x => x.CreateListenTask(It.IsAny<CancellationToken>()))
......
......@@ -62,7 +62,7 @@ public bool TryConnectToNamedPipeWithSpinWait(int timeoutMs, CancellationToken c
{
using (var pipeStream = new NamedPipeClientStream(".", _pipeName, PipeDirection.InOut, PipeOptions.Asynchronous))
{
return TryConnectToNamedPipeWithSpinWait(pipeStream, timeoutMs, cancellationToken);
return BuildServerConnection.TryConnectToNamedPipeWithSpinWait(pipeStream, timeoutMs, cancellationToken);
}
}
}
......@@ -127,7 +127,7 @@ public void ConnectToServerFails()
// compilation.
bool holdsMutex;
using (var serverMutex = new Mutex(initiallyOwned: true,
name: DesktopBuildClient.GetServerMutexName(_pipeName),
name: BuildServerConnection.GetServerMutexName(_pipeName),
createdNew: out holdsMutex))
{
Assert.True(holdsMutex);
......@@ -371,10 +371,10 @@ public class MiscTest
public void GetBasePipeNameSlashes()
{
var path = string.Format(@"q:{0}the{0}path", Path.DirectorySeparatorChar);
var name = DesktopBuildClient.GetBasePipeName(path);
Assert.Equal(name, DesktopBuildClient.GetBasePipeName(path));
Assert.Equal(name, DesktopBuildClient.GetBasePipeName(path + Path.DirectorySeparatorChar));
Assert.Equal(name, DesktopBuildClient.GetBasePipeName(path + Path.DirectorySeparatorChar + Path.DirectorySeparatorChar));
var name = BuildServerConnection.GetBasePipeName(path);
Assert.Equal(name, BuildServerConnection.GetBasePipeName(path));
Assert.Equal(name, BuildServerConnection.GetBasePipeName(path + Path.DirectorySeparatorChar));
Assert.Equal(name, BuildServerConnection.GetBasePipeName(path + Path.DirectorySeparatorChar + Path.DirectorySeparatorChar));
}
}
}
......
......@@ -95,7 +95,7 @@ internal static BuildPaths CreateBuildPaths(string workingDir, string tempDir)
var serverStatsSource = new TaskCompletionSource<ServerStats>();
var serverListenSource = new TaskCompletionSource<bool>();
var cts = new CancellationTokenSource();
var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
var thread = new Thread(_ =>
{
var listener = new TestableDiagnosticListener();
......@@ -122,7 +122,7 @@ internal static BuildPaths CreateBuildPaths(string workingDir, string tempDir)
// The contract of this function is that it will return once the server has started. Spin here until
// we can verify the server has started or simply failed to start.
while (DesktopBuildClient.WasServerMutexOpen(mutexName) != true && thread.IsAlive)
while (BuildServerConnection.WasServerMutexOpen(mutexName) != true && thread.IsAlive)
{
Thread.Yield();
}
......@@ -143,7 +143,7 @@ internal static ServerData CreateServerFailsConnection(string pipeName = null)
{
var thread = new Thread(_ =>
{
var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
bool holdsMutex;
using (var serverMutex = new Mutex(initiallyOwned: true,
name: mutexName,
......
......@@ -55,7 +55,7 @@ public async Task NoServerConnection()
using (var doneMre = new ManualResetEvent(initialState: false))
{
var pipeName = Guid.NewGuid().ToString();
var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
bool created = false;
bool connected = false;
......@@ -104,7 +104,7 @@ public async Task ServerShutdownsDuringProcessing()
using (var doneMre = new ManualResetEvent(initialState: false))
{
var pipeName = Guid.NewGuid().ToString();
var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
bool created = false;
bool connected = false;
......
......@@ -207,46 +207,5 @@ private static IEnumerable<string> GetCommandLineWindows(IEnumerable<string> arg
// The first argument will be the executable name hence we skip it.
return CommandLineParser.SplitCommandLineIntoArguments(commandLine, removeHashComments: false).Skip(1);
}
/// <summary>
/// Gets the value of the temporary path for the current environment assuming the working directory
/// is <paramref name="workingDir"/>. This function must emulate <see cref="Path.GetTempPath"/> as
/// closely as possible.
/// </summary>
public static string GetTempPath(string workingDir)
{
var tmp = Environment.GetEnvironmentVariable("TMP");
if (Path.IsPathRooted(tmp))
{
return tmp;
}
var temp = Environment.GetEnvironmentVariable("TEMP");
if (Path.IsPathRooted(temp))
{
return temp;
}
if (!string.IsNullOrEmpty(workingDir))
{
if (!string.IsNullOrEmpty(tmp))
{
return Path.Combine(workingDir, tmp);
}
if (!string.IsNullOrEmpty(temp))
{
return Path.Combine(workingDir, temp);
}
}
var userProfile = Environment.GetEnvironmentVariable("USERPROFILE");
if (Path.IsPathRooted(userProfile))
{
return userProfile;
}
return Environment.GetEnvironmentVariable("SYSTEMROOT");
}
}
}
此差异已折叠。
......@@ -32,7 +32,7 @@ internal static int Run(IEnumerable<string> arguments, RequestLanguage language,
var client = new CoreClrBuildClient(language, compileFunc);
var clientDir = AppContext.BaseDirectory;
var workingDir = Directory.GetCurrentDirectory();
var tempDir = GetTempPath(workingDir);
var tempDir = Path.GetTempPath();
var buildPaths = new BuildPaths(clientDir: clientDir, workingDir: workingDir, sdkDir: null, tempDir: tempDir);
return client.RunCompilation(arguments, buildPaths).ExitCode;
}
......
......@@ -1290,7 +1290,7 @@ lVbRuntimePlus:
keyFileSearchPaths.Add(outputDirectory)
End If
Dim parsedFeatures = CompilerOptionParseUtilities.ParseFeatures(features)
Dim parsedFeatures = ParseFeatures(features)
Dim compilationName As String = Nothing
GetCompilationAndModuleNames(diagnostics, outputKind, sourceFiles, moduleAssemblyName, outputFileName, moduleName, compilationName)
......
......@@ -44,6 +44,9 @@
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\Shared\BuildClient.cs">
<Link>BuildClient.cs</Link>
</Compile>
<Compile Include="..\..\Shared\CoreClrAnalyzerAssemblyLoader.cs">
<Link>CoreClrAnalyzerAssemblyLoader.cs</Link>
</Compile>
......@@ -69,4 +72,4 @@
</ItemGroup>
<Import Project="..\..\Core\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</Project>
</Project>
\ No newline at end of file
......@@ -35,6 +35,12 @@
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\BuildClient.cs">
<Link>BuildClient.cs</Link>
</Compile>
<Compile Include="..\..\Shared\BuildServerConnection.cs">
<Link>BuildServerConnection.cs</Link>
</Compile>
<Compile Include="..\..\Shared\DesktopBuildClient.cs">
<Link>DesktopBuildClient.cs</Link>
</Compile>
......@@ -61,4 +67,4 @@
</ItemGroup>
<Import Project="..\..\Core\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</Project>
</Project>
\ No newline at end of file
......@@ -14,7 +14,7 @@
<CopyNuGetImplementations>false</CopyNuGetImplementations>
</PropertyGroup>
<ItemGroup Label="Linked Files">
<Compile Include="..\..\..\..\..\Compilers\Core\Portable\UnicodeCharacterUtilities.cs">
<Compile Include="..\..\..\..\..\Compilers\Core\Portable\InternalUtilities\UnicodeCharacterUtilities.cs">
<Link>Compiler\Parser\UnicodeCharacterUtilities.cs</Link>
</Compile>
<Compile Include="..\..\..\..\..\Compilers\CSharp\Portable\Parser\CharacterInfo.cs">
......
......@@ -14,7 +14,7 @@
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<ItemGroup Label="Linked Files">
<Compile Include="..\..\..\..\..\Compilers\Core\Portable\UnicodeCharacterUtilities.cs">
<Compile Include="..\..\..\..\..\Compilers\Core\Portable\InternalUtilities\UnicodeCharacterUtilities.cs">
<Link>Compiler\Parser\UnicodeCharacterUtilities.cs</Link>
</Compile>
<Compile Include="..\..\..\..\..\Compilers\CSharp\Portable\Parser\CharacterInfo.cs">
......
......@@ -24,6 +24,8 @@
<dependency id="System.Security.AccessControl" version="$SystemSecurityAccessControlVersion$" />
<dependency id="System.Security.Cryptography.Algorithms" version="$SystemSecurityCryptographyAlgorithmsVersion$"/>
<dependency id="System.Security.Principal.Windows" version="$SystemSecurityPrincipalWindowsVersion$" />
<dependency id="System.Text.Encoding" version="$SystemTextEncodingVersion$"/>
<dependency id="System.Text.Encoding.Extensions" version="$SystemTextEncodingExtensionsVersion$"/>
<dependency id="System.Text.RegularExpressions" version="$SystemTextRegularExpressionsVersion$"/>
<dependency id="System.Threading.Thread" version="$SystemThreadingThreadVersion$" />
</group>
......
......@@ -289,8 +289,8 @@
<InternalsVisibleToMoq Include="DynamicProxyGenAssembly2" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\Compilers\Core\Portable\UnicodeCharacterUtilities.cs">
<Link>Shared\UnicodeCharacterUtilities.cs</Link>
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\UnicodeCharacterUtilities.cs">
<Link>InternalUtilities\UnicodeCharacterUtilities.cs</Link>
</Compile>
<Compile Include="CaseCorrection\AbstractCaseCorrectionService.cs" />
<Compile Include="CaseCorrection\CaseCorrector.cs" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册