Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Roslyn.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@
<Project Path="src/Workspaces/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Workspaces.csproj" />
<Project Path="src/Workspaces/CSharpTest/Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests.csproj" />
<Project Path="src/Workspaces/MSBuild/BuildHost/Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.csproj" />
<Project Path="src/Workspaces/MSBuild/Contracts/Microsoft.CodeAnalysis.Workspaces.MSBuild.Contracts.csproj" />
<Project Path="src/Workspaces/MSBuild/Core/Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj" />
<Project Path="src/Workspaces/MSBuild/Test/Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests.csproj" />
<Project Path="src/Workspaces/Remote/Core/Microsoft.CodeAnalysis.Remote.Workspaces.csproj" />
Expand Down
1 change: 1 addition & 0 deletions eng/config/PublishData.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"Microsoft.CodeAnalysis.Scripting.Common": "arcade",
"Microsoft.CodeAnalysis.Workspaces.Common": "vssdk",
"Microsoft.CodeAnalysis.Workspaces.MSBuild": "arcade",
"Microsoft.CodeAnalysis.Workspaces.MSBuild.Contracts": "arcade",
"Microsoft.CodeAnalysis.Workspaces.Desktop": "arcade",
"Microsoft.CodeAnalysis.Workspaces.Test.Utilities": "vs-impl",
"Microsoft.CodeAnalysis.Compiler.Test.Resources": "vs-impl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Composition;
using System.Diagnostics;
using System.Text;
using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.Extensions.Logging;
using Roslyn.Utilities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Microsoft.CodeAnalysis.Features.Workspaces;
using Microsoft.CodeAnalysis.LanguageServer.HostWorkspace;
using Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.ProjectTelemetry;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.ProjectSystem;
using Microsoft.CodeAnalysis.Shared.Extensions;
Expand All @@ -17,7 +16,6 @@
using Microsoft.CodeAnalysis.Workspaces.ProjectSystem;
using Microsoft.Extensions.Logging;
using Roslyn.Utilities;
using static Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager;

namespace Microsoft.CodeAnalysis.LanguageServer.FileBasedPrograms;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Features.Workspaces;
using Microsoft.CodeAnalysis.LanguageServer.HostWorkspace;
using Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.ProjectTelemetry;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.ProjectSystem;
using Microsoft.CodeAnalysis.Shared.Extensions;
Expand All @@ -17,7 +14,6 @@
using Microsoft.CommonLanguageServerProtocol.Framework;
using Microsoft.Extensions.Logging;
using Roslyn.LanguageServer.Protocol;
using static Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager;

namespace Microsoft.CodeAnalysis.LanguageServer.FileBasedPrograms;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.LanguageServer.Handler;
using Microsoft.CodeAnalysis.LanguageServer.HostWorkspace;
using Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.ProjectTelemetry;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.ProjectSystem;
using Microsoft.CodeAnalysis.Shared.TestHooks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.LanguageServer.HostWorkspace;
using Microsoft.CodeAnalysis.Options;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

extern alias MSBuildWorkspaces;
extern alias MSBuildWorkspacesContracts;

global using MSBuildWorkspaces::Microsoft.CodeAnalysis.MSBuild;
global using MSBuildWorkspacesContracts::Microsoft.CodeAnalysis.MSBuild;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System.Composition;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis.Options;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.Composition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,16 @@
using System.Diagnostics;
using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.LanguageServer.Handler.DebugConfiguration;
using Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.ProjectTelemetry;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.ProjectSystem;
using Microsoft.CodeAnalysis.Shared.Collections;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Microsoft.CodeAnalysis.Threading;
using Microsoft.CodeAnalysis.Workspaces.ProjectSystem;
using Microsoft.Extensions.Logging;
using Roslyn.Utilities;
using static Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager;
using LSP = Roslyn.LanguageServer.Protocol;

namespace Microsoft.CodeAnalysis.LanguageServer.HostWorkspace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
using System.Composition;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.ProjectTelemetry;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.ProjectSystem;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Workspaces.ProjectSystem;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.Composition;
using Roslyn.Utilities;
using static Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager;

namespace Microsoft.CodeAnalysis.LanguageServer.HostWorkspace;

Expand Down Expand Up @@ -87,7 +84,7 @@ public async Task OpenProjectsAsync(ImmutableArray<string> projectFilePaths)
if (!_projectFileExtensionRegistry.TryGetLanguageNameFromProjectPath(projectPath, DiagnosticReportingMode.Ignore, out var languageName))
return null;

var preferredBuildHostKind = GetKindForProject(projectPath);
var preferredBuildHostKind = BuildHostProcessManager.GetKindForProject(projectPath);
var (buildHost, actualBuildHostKind) = await buildHostProcessManager.GetBuildHostWithFallbackAsync(preferredBuildHostKind, projectPath, cancellationToken);

var loadedFile = await buildHost.LoadProjectFileAsync(projectPath, languageName, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
// See the LICENSE file in the project root for more information.

using System.Collections.Immutable;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.LanguageServer.Handler.DebugConfiguration;
using Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.FileWatching;
using Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.ProjectTelemetry;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis.ProjectSystem;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.Workspaces.ProjectSystem;
using Microsoft.Extensions.FileSystemGlobbing;
using Microsoft.Extensions.Logging;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.LanguageServer.Handler;
using Microsoft.CodeAnalysis.LanguageServer.LanguageServer;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.Extensions.Logging;
using NuGet.ProjectModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Composition;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.LanguageServer.LanguageServer;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.Extensions.Logging;
using Roslyn.Utilities;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.

using System.Text.Json.Serialization;
using Roslyn.LanguageServer.Protocol;

namespace Microsoft.CodeAnalysis.LanguageServer.Handler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@
</Target>

<ItemGroup Label="Project References">
<ProjectReference Include="..\..\Workspaces\MSBuild\Core\Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj" />
<!-- An extern alias is necessary to prevent ambiguity between shared projects linked to both Workspace and BuildHost -->
<ProjectReference Include="..\..\Workspaces\MSBuild\Core\Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj" Aliases="MSBuildWorkspaces" />
<ProjectReference Include="..\..\Workspaces\MSBuild\Contracts\Microsoft.CodeAnalysis.Workspaces.MSBuild.Contracts.csproj" Aliases="MSBuildWorkspacesContracts" />

<ProjectReference Include="..\..\Workspaces\Remote\Core\Microsoft.CodeAnalysis.Remote.Workspaces.csproj" />
<ProjectReference Include="..\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.dll" TargetDir="" />
<_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Workspaces.Desktop\$(Configuration)\net472\Microsoft.CodeAnalysis.Workspaces.Desktop.dll" TargetDir="" />
<_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost\$(Configuration)\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.exe" TargetDir="" />
<_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Workspaces.MSBuild.Contracts\$(Configuration)\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.Contracts.dll" TargetDir="" />
<_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Workspaces.MSBuild\$(Configuration)\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll" TargetDir="" />
<_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Workspaces\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Workspaces.dll" TargetDir="" />
<_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.dll" TargetDir="" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
<None Include="Rpc\Readme.md" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Contracts\Microsoft.CodeAnalysis.Workspaces.MSBuild.Contracts.csproj" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="WorkspaceMSBuildBuildHostResources.resx" GenerateSource="true" />
</ItemGroup>
Expand All @@ -101,6 +105,5 @@
</Target>
<Import Project="..\..\..\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems" Label="Shared" />
<Import Project="..\..\..\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems" Label="Shared" />
<Import Project="..\..\..\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems" Label="Shared" />
<Import Project="$(RepositoryEngineeringDir)targets\PackageDownloadAndReference.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis</RootNamespace>
<TargetFrameworks>$(NetRoslynBuildHostNetCoreVersion);net472</TargetFrameworks>

<!-- NuGet -->
<IsPackable>true</IsPackable>
<PackageDescription>
.NET Compiler Platform ("Roslyn") MSBuild host RPC contracts.
</PackageDescription>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" />
<PackageReference Include="System.Threading.Tasks.Extensions" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
<PackageReference Include="System.Text.Json" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
</ItemGroup>
<ItemGroup>
<PublicAPI Include="PublicAPI.Shipped.txt" />
<PublicAPI Include="PublicAPI.Unshipped.txt" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LanguageServer" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests" />
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" Key="$(MoqPublicKey)" LoadsWithinVisualStudio="false" />
</ItemGroup>
<Import Project="..\..\..\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems" Label="Shared" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.MSBuild;

Expand All @@ -20,6 +19,9 @@ internal static class MonoMSBuildDiscovery
private static string? s_monoMSBuildDirectory;
private static string? s_monoVersionString;

private static void RequireUnix()
=> Contract.ThrowIfTrue(Path.DirectorySeparatorChar == '\\');

private static IEnumerable<string> GetSearchPaths()
{
if (s_searchPaths == null)
Expand Down Expand Up @@ -53,10 +55,7 @@ private static IEnumerable<string> GetSearchPaths()
/// </summary>
private static string? RealPath(string path)
{
if (PlatformInformation.IsWindows)
{
throw new PlatformNotSupportedException($"{nameof(RealPath)} can only be called on Unix.");
}
RequireUnix();

var ptr = Unix_realpath(path, IntPtr.Zero);
var result = Marshal.PtrToStringAnsi(ptr); // uses UTF8 on Unix
Expand All @@ -70,7 +69,7 @@ private static IEnumerable<string> GetSearchPaths()
/// </summary>
private static string? GetMonoRuntimeExecutablePath()
{
Contract.ThrowIfTrue(PlatformInformation.IsWindows);
RequireUnix();

if (s_monoRuntimeExecutablePath == null)
{
Expand All @@ -94,7 +93,7 @@ private static IEnumerable<string> GetSearchPaths()
/// </summary>
private static string? GetMonoLibDirPath()
{
Contract.ThrowIfTrue(PlatformInformation.IsWindows);
RequireUnix();

const string DefaultMonoLibPath = "/usr/lib/mono";
if (Directory.Exists(DefaultMonoLibPath))
Expand Down Expand Up @@ -131,7 +130,7 @@ private static IEnumerable<string> GetSearchPaths()
/// </summary>
public static string? GetMonoMSBuildDirectory()
{
Contract.ThrowIfTrue(PlatformInformation.IsWindows);
RequireUnix();

if (s_monoMSBuildDirectory == null)
{
Expand Down Expand Up @@ -164,7 +163,7 @@ private static IEnumerable<string> GetSearchPaths()

public static string? GetMonoMSBuildVersion()
{
Contract.ThrowIfTrue(PlatformInformation.IsWindows);
RequireUnix();

if (s_monoVersionString == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System.Collections.Immutable;
using System.Runtime.Serialization;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.MSBuild;

Expand Down Expand Up @@ -144,7 +143,7 @@ internal sealed class ProjectFileInfo
public ImmutableArray<FileGlobs> FileGlobs { get; init; }

public override string ToString()
=> RoslynString.IsNullOrWhiteSpace(TargetFramework)
=> string.IsNullOrWhiteSpace(TargetFramework)
? FilePath ?? string.Empty
: $"{FilePath} ({TargetFramework})";

Expand Down
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions src/Workspaces/MSBuild/Core/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

extern alias Contracts;
global using Contracts::Microsoft.CodeAnalysis.MSBuild;
12 changes: 12 additions & 0 deletions src/Workspaces/MSBuild/Core/MSBuild/BuildHostProcessKind.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace Microsoft.CodeAnalysis.MSBuild;

internal enum BuildHostProcessKind
{
NetCore,
NetFramework,
Mono
}
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,6 @@ public static BuildHostProcessKind GetKindForProject(string projectFilePath)
#endif
}

public enum BuildHostProcessKind
{
NetCore,
NetFramework,
Mono
}

private sealed class BuildHostProcess : IAsyncDisposable
{
private readonly ILogger? _logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<ProjectReference Include="..\..\..\Tools\ExternalAccess\RazorCompiler\Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler.csproj" PrivateAssets="all">
<IncludeOutputInThisPackage>true</IncludeOutputInThisPackage>
</ProjectReference>

<!-- An extern alias is necessary to prevent ambiguity between shared projects linked to both Workspace and BuildHost -->
<ProjectReference Include="..\Contracts\Microsoft.CodeAnalysis.Workspaces.MSBuild.Contracts.csproj" Aliases="Contracts" />
</ItemGroup>
<ItemGroup>
<PublicAPI Include="PublicAPI.Shipped.txt" />
Expand All @@ -56,7 +59,6 @@
<Link>InternalUtilities\GlobalAssemblyCache.cs</Link>
</Compile>
<Compile Include="..\..\..\Compilers\Shared\NamedPipeUtil.cs" Link="InternalUtilities\NamedPipeUtil.cs" />
<Compile Include="..\BuildHost\Rpc\Contracts\*.cs" Link="Rpc\Contracts\%(FileName).cs"/>
</ItemGroup>
<ItemGroup>
<None Include="..\BuildHost\Rpc\Readme.md" Link="Rpc\Readme.md" />
Expand Down
Loading