diff --git a/eng/Versions.props b/eng/Versions.props
index 241e4ad538cc6..2443262159793 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -58,7 +58,7 @@
6.1.0.5902
$(MicrosoftBuildPackagesVersion)
$(MicrosoftBuildPackagesVersion)
- 1.2.6
+ 1.4.1
$(MicrosoftBuildPackagesVersion)
$(MicrosoftBuildPackagesVersion)
5.7.0
@@ -194,6 +194,17 @@
6.6.0.161
4.10.1
2.7.74
+
+ 5.10.0
+ 5.10.0
+ 5.10.0
+ 5.10.0
+ 5.10.0
+ 5.10.0
4.0.0-rc-2048
4.8.0
1.1.0-beta1-62506-02
diff --git a/src/Workspaces/MSBuildTest/DotNetSdkMSBuildInstalled.cs b/src/Workspaces/MSBuildTest/DotNetSdkMSBuildInstalled.cs
new file mode 100644
index 0000000000000..31d92339f03c2
--- /dev/null
+++ b/src/Workspaces/MSBuildTest/DotNetSdkMSBuildInstalled.cs
@@ -0,0 +1,48 @@
+// 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.
+
+using System;
+using System.Linq;
+using Microsoft.Build.Locator;
+using Roslyn.Test.Utilities;
+
+namespace Microsoft.CodeAnalysis.MSBuild.UnitTests
+{
+ internal partial class DotNetSdkMSBuildInstalled : ExecutionCondition
+ {
+ private static readonly VisualStudioInstance? s_instance;
+
+ static DotNetSdkMSBuildInstalled()
+ {
+ s_instance = MSBuildLocator.QueryVisualStudioInstances()
+ .OrderByDescending(instances => instances.Version)
+ .FirstOrDefault();
+
+ if (s_instance != null && !MSBuildLocator.IsRegistered)
+ {
+ MSBuildLocator.RegisterInstance(s_instance);
+ }
+ }
+
+ private readonly Version _minimumVersion;
+
+ public DotNetSdkMSBuildInstalled() : this(new Version(2, 1))
+ {
+ }
+
+ internal DotNetSdkMSBuildInstalled(Version minimumVersion)
+ {
+ _minimumVersion = minimumVersion;
+ }
+
+ public override bool ShouldSkip => s_instance is null || s_instance.Version < _minimumVersion;
+
+ public override string SkipReason
+#if NETCOREAPP
+ => $"Could not locate .NET SDK {_minimumVersion} or higher installed.";
+#else
+ => $"Test runs on .NET Core only.";
+#endif
+ }
+}
diff --git a/src/Workspaces/MSBuildTest/Interop.cs b/src/Workspaces/MSBuildTest/Interop.cs
deleted file mode 100644
index 6251771c56238..0000000000000
--- a/src/Workspaces/MSBuildTest/Interop.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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.
-
-#nullable disable
-
-using System;
-using System.Runtime.InteropServices;
-using Microsoft.VisualStudio.Setup.Configuration;
-
-namespace Microsoft.CodeAnalysis.MSBuild.UnitTests
-{
- internal static class Interop
- {
- private const int REGDG_E_CLASSNOTREG = unchecked((int)0x80040154);
-
- [DllImport("Microsoft.VisualStudio.Setup.Configuration.Native.dll", ExactSpelling = true, PreserveSig = true)]
- private static extern int GetSetupConfiguration(
- [MarshalAs(UnmanagedType.Interface), Out] out ISetupConfiguration configuration,
- IntPtr reserved);
-
- public static ISetupConfiguration2 GetSetupConfiguration()
- {
- try
- {
- return new SetupConfiguration();
- }
- catch (COMException ex) when (ex.ErrorCode == REGDG_E_CLASSNOTREG)
- {
- // We could not CoCreate the SetupConfiguration object. If that fails, try p/invoking.
- var hresult = GetSetupConfiguration(out var configuration, IntPtr.Zero);
-
- if (hresult < 0)
- {
- throw new COMException($"Failed to get {nameof(ISetupConfiguration)}", hresult);
- }
-
- return configuration as ISetupConfiguration2;
- }
- }
- }
-}
diff --git a/src/Workspaces/MSBuildTest/MSBuildInstalled.cs b/src/Workspaces/MSBuildTest/MSBuildInstalled.cs
new file mode 100644
index 0000000000000..fc7b66fddc858
--- /dev/null
+++ b/src/Workspaces/MSBuildTest/MSBuildInstalled.cs
@@ -0,0 +1,58 @@
+// 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.
+
+using System;
+using Roslyn.Test.Utilities;
+
+namespace Microsoft.CodeAnalysis.MSBuild.UnitTests
+{
+ ///
+ /// These tests will run with either VS installed or with a .NET (Core) SDK installed. The
+ /// MSBuild used depends on the TargetFramework of the test project being executed.
+ ///
+ internal class MSBuildInstalled : ExecutionCondition
+ {
+ private readonly ExecutionCondition _msBuildInstalled;
+
+ public MSBuildInstalled()
+ : this(minimumVsVersion: new Version(15, 0), minimumSdkVersion: new Version(2, 1))
+ {
+ }
+
+ ///
+ /// These tests will run with either the VS installed or with a .NET (Core) SDK installed. The
+ /// MSBuild used depends on the TargetFramework of the test project being executed. Include valid
+ /// minimum versions for both.
+ ///
+ protected MSBuildInstalled(Version minimumVsVersion, Version minimumSdkVersion)
+ {
+ _msBuildInstalled =
+#if NETCOREAPP
+ new DotNetSdkMSBuildInstalled(minimumSdkVersion);
+#else
+ new VisualStudioMSBuildInstalled(minimumVsVersion);
+#endif
+ }
+
+ public override bool ShouldSkip => _msBuildInstalled.ShouldSkip;
+
+ public override string SkipReason => _msBuildInstalled.SkipReason;
+ }
+
+ internal class MSBuild16_2OrHigherInstalled : MSBuildInstalled
+ {
+ public MSBuild16_2OrHigherInstalled()
+ : base(minimumVsVersion: new Version(16, 2), minimumSdkVersion: new Version(3, 1))
+ {
+ }
+ }
+
+ internal class MSBuild16_9OrHigherInstalled : MSBuildInstalled
+ {
+ public MSBuild16_9OrHigherInstalled()
+ : base(minimumVsVersion: new Version(16, 9), minimumSdkVersion: new Version(5, 0, 201))
+ {
+ }
+ }
+}
diff --git a/src/Workspaces/MSBuildTest/MSBuildWorkspaceTests.cs b/src/Workspaces/MSBuildTest/MSBuildWorkspaceTests.cs
index 2e88834903b65..2f280658fe2bc 100644
--- a/src/Workspaces/MSBuildTest/MSBuildWorkspaceTests.cs
+++ b/src/Workspaces/MSBuildTest/MSBuildWorkspaceTests.cs
@@ -34,7 +34,7 @@ namespace Microsoft.CodeAnalysis.MSBuild.UnitTests
{
public class MSBuildWorkspaceTests : MSBuildWorkspaceTestBase
{
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public void TestCreateMSBuildWorkspace()
{
using var workspace = CreateMSBuildWorkspace();
@@ -48,7 +48,7 @@ public void TestCreateMSBuildWorkspace()
Assert.NotNull(workspace.Services.TextFactory);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_SingleProjectSolution()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -64,7 +64,7 @@ public async Task TestOpenSolution_SingleProjectSolution()
Assert.StartsWith("public class CSharpClass", type.ToString(), StringComparison.Ordinal);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_MultiProjectSolution()
{
CreateFiles(GetMultiProjectSolutionFiles());
@@ -89,7 +89,7 @@ public async Task TestOpenSolution_MultiProjectSolution()
Assert.Equal(5, compReferences.Count);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled), AlwaysSkip = "https://github.com/dotnet/roslyn/issues/41456"), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled), AlwaysSkip = "https://github.com/dotnet/roslyn/issues/41456"), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(2824, "https://github.com/dotnet/roslyn/issues/2824")]
public async Task Test_OpenProjectReferencingPortableProject()
{
@@ -112,7 +112,7 @@ public async Task Test_OpenProjectReferencingPortableProject()
string.Join(Environment.NewLine, project.MetadataReferences.OfType().Select(r => r.FilePath)));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task Test_SharedMetadataReferences()
{
CreateFiles(GetMultiProjectSolutionFiles());
@@ -135,7 +135,7 @@ public async Task Test_SharedMetadataReferences()
Assert.Same(p0mscorlib, p1mscorlib);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(546171, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546171")]
public async Task Test_SharedMetadataReferencesWithAliases()
{
@@ -203,7 +203,7 @@ private static MetadataReference GetMetadataReferenceByAlias(Project project, st
private static Metadata GetMetadata(MetadataReference metadataReference)
=> ((PortableExecutableReference)metadataReference).GetMetadata();
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(552981, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/552981")]
public async Task TestOpenSolution_DuplicateProjectGuids()
{
@@ -214,7 +214,7 @@ public async Task TestOpenSolution_DuplicateProjectGuids()
var solution = await workspace.OpenSolutionAsync(solutionFilePath);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(831379, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/831379")]
public async Task GetCompilationWithCircularProjectReferences()
{
@@ -239,7 +239,7 @@ public async Task GetCompilationWithCircularProjectReferences()
compilation2.References.OfType().Any(c => c.Compilation == compilation1));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOutputFilePaths()
{
CreateFiles(GetMultiProjectSolutionFiles());
@@ -254,7 +254,7 @@ public async Task TestOutputFilePaths()
Assert.Equal("VisualBasicProject.dll", Path.GetFileName(p2.OutputFilePath));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOutputInfo()
{
CreateFiles(GetMultiProjectSolutionFiles());
@@ -269,7 +269,7 @@ public async Task TestCompilationOutputInfo()
Assert.Equal("VisualBasicProject.dll", Path.GetFileName(p2.CompilationOutputInfo.AssemblyPath));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCrossLanguageReferencesUsesInMemoryGeneratedMetadata()
{
CreateFiles(GetMultiProjectSolutionFiles());
@@ -291,7 +291,7 @@ public async Task TestCrossLanguageReferencesUsesInMemoryGeneratedMetadata()
Assert.NotNull(pref);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCrossLanguageReferencesWithOutOfDateMetadataOnDiskUsesInMemoryGeneratedMetadata()
{
await PrepareCrossLanguageProjectWithEmittedMetadataAsync();
@@ -318,7 +318,7 @@ public async Task TestCrossLanguageReferencesWithOutOfDateMetadataOnDiskUsesInMe
Assert.NotNull(pref);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestInternalsVisibleToSigned()
{
var solution = await SolutionAsync(
@@ -346,7 +346,7 @@ class C1
Assert.Empty(diagnostics);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestVersions()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -391,7 +391,7 @@ public async Task TestVersions()
Assert.True(solution3.Version.GetTestAccessor().IsNewerThan(solution2.Version));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_LoadMetadataForReferencedProjects()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -410,7 +410,7 @@ public async Task TestOpenSolution_LoadMetadataForReferencedProjects()
Assert.StartsWith("public class CSharpClass", type.ToString(), StringComparison.Ordinal);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(33047, "https://github.com/dotnet/roslyn/issues/33047")]
public async Task TestOpenProject_CSharp_GlobalPropertyShouldUnsetParentConfigurationAndPlatformDefault()
{
@@ -428,7 +428,7 @@ public async Task TestOpenProject_CSharp_GlobalPropertyShouldUnsetParentConfigur
Assert.Equal(expectedFileName, tree.FilePath);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(33047, "https://github.com/dotnet/roslyn/issues/33047")]
public async Task TestOpenProject_CSharp_GlobalPropertyShouldUnsetParentConfigurationAndPlatformTrue()
{
@@ -446,7 +446,7 @@ public async Task TestOpenProject_CSharp_GlobalPropertyShouldUnsetParentConfigur
Assert.Equal(expectedFileName, tree.FilePath);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(739043, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/739043")]
public async Task TestOpenProject_CSharp_WithoutPrefer32BitAndConsoleApplication()
{
@@ -460,7 +460,7 @@ public async Task TestOpenProject_CSharp_WithoutPrefer32BitAndConsoleApplication
Assert.Equal(Platform.AnyCpu, compilation.Options.Platform);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(739043, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/739043")]
public async Task TestOpenProject_CSharp_WithoutPrefer32BitAndLibrary()
{
@@ -475,7 +475,7 @@ public async Task TestOpenProject_CSharp_WithoutPrefer32BitAndLibrary()
Assert.Equal(Platform.AnyCpu, compilation.Options.Platform);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(739043, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/739043")]
public async Task TestOpenProject_CSharp_WithPrefer32BitAndConsoleApplication()
{
@@ -489,7 +489,7 @@ public async Task TestOpenProject_CSharp_WithPrefer32BitAndConsoleApplication()
Assert.Equal(Platform.AnyCpu32BitPreferred, compilation.Options.Platform);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(739043, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/739043")]
public async Task TestOpenProject_CSharp_WithPrefer32BitAndLibrary()
{
@@ -504,7 +504,7 @@ public async Task TestOpenProject_CSharp_WithPrefer32BitAndLibrary()
Assert.Equal(Platform.AnyCpu, compilation.Options.Platform);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(739043, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/739043")]
public async Task TestOpenProject_CSharp_WithPrefer32BitAndWinMDObj()
{
@@ -519,7 +519,7 @@ public async Task TestOpenProject_CSharp_WithPrefer32BitAndWinMDObj()
Assert.Equal(Platform.AnyCpu, compilation.Options.Platform);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_CSharp_WithoutOutputPath()
{
CreateFiles(GetSimpleCSharpSolutionFiles()
@@ -531,7 +531,7 @@ public async Task TestOpenProject_CSharp_WithoutOutputPath()
Assert.NotEmpty(project.OutputFilePath);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_CSharp_WithoutAssemblyName()
{
CreateFiles(GetSimpleCSharpSolutionFiles()
@@ -543,7 +543,7 @@ public async Task TestOpenProject_CSharp_WithoutAssemblyName()
Assert.NotEmpty(project.OutputFilePath);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_CSharp_WithoutCSharpTargetsImported_DocumentsArePickedUp()
{
CreateFiles(GetSimpleCSharpSolutionFiles()
@@ -556,7 +556,7 @@ public async Task TestOpenSolution_CSharp_WithoutCSharpTargetsImported_Documents
Assert.NotEmpty(project.Documents);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_VisualBasic_WithoutVBTargetsImported_DocumentsArePickedUp()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -568,7 +568,7 @@ public async Task TestOpenProject_VisualBasic_WithoutVBTargetsImported_Documents
Assert.NotEmpty(project.Documents);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(739043, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/739043")]
public async Task TestOpenProject_VisualBasic_WithoutPrefer32BitAndConsoleApplication()
{
@@ -582,7 +582,7 @@ public async Task TestOpenProject_VisualBasic_WithoutPrefer32BitAndConsoleApplic
Assert.Equal(Platform.AnyCpu, compilation.Options.Platform);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(739043, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/739043")]
public async Task TestOpenProject_VisualBasic_WithoutPrefer32BitAndLibrary()
{
@@ -597,7 +597,7 @@ public async Task TestOpenProject_VisualBasic_WithoutPrefer32BitAndLibrary()
Assert.Equal(Platform.AnyCpu, compilation.Options.Platform);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(739043, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/739043")]
public async Task TestOpenProject_VisualBasic_WithPrefer32BitAndConsoleApplication()
{
@@ -611,7 +611,7 @@ public async Task TestOpenProject_VisualBasic_WithPrefer32BitAndConsoleApplicati
Assert.Equal(Platform.AnyCpu32BitPreferred, compilation.Options.Platform);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(739043, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/739043")]
public async Task TestOpenProject_VisualBasic_WithPrefer32BitAndLibrary()
{
@@ -626,7 +626,7 @@ public async Task TestOpenProject_VisualBasic_WithPrefer32BitAndLibrary()
Assert.Equal(Platform.AnyCpu, compilation.Options.Platform);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(739043, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/739043")]
public async Task TestOpenProject_VisualBasic_WithPrefer32BitAndWinMDObj()
{
@@ -641,7 +641,7 @@ public async Task TestOpenProject_VisualBasic_WithPrefer32BitAndWinMDObj()
Assert.Equal(Platform.AnyCpu, compilation.Options.Platform);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_VisualBasic_WithoutOutputPath()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -654,7 +654,7 @@ public async Task TestOpenProject_VisualBasic_WithoutOutputPath()
Assert.NotEmpty(project.OutputFilePath);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_VisualBasic_WithLanguageVersion15_3()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -666,7 +666,7 @@ public async Task TestOpenProject_VisualBasic_WithLanguageVersion15_3()
Assert.Equal(VB.LanguageVersion.VisualBasic15_3, ((VB.VisualBasicParseOptions)project.ParseOptions).LanguageVersion);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_VisualBasic_WithLatestLanguageVersion()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -679,7 +679,7 @@ public async Task TestOpenProject_VisualBasic_WithLatestLanguageVersion()
Assert.Equal(VB.LanguageVersion.Latest, ((VB.VisualBasicParseOptions)project.ParseOptions).SpecifiedLanguageVersion);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_VisualBasic_WithoutAssemblyName()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -693,7 +693,7 @@ public async Task TestOpenProject_VisualBasic_WithoutAssemblyName()
Assert.NotEmpty(project.OutputFilePath);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task Test_Respect_ReferenceOutputassembly_Flag()
{
CreateFiles(GetSimpleCSharpSolutionFiles()
@@ -706,38 +706,7 @@ public async Task Test_Respect_ReferenceOutputassembly_Flag()
Assert.Empty(project.ProjectReferences);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
- public async Task TestOpenProject_WithXaml()
- {
- CreateFiles(GetSimpleCSharpSolutionFiles()
- .WithFile(@"CSharpProject\CSharpProject.csproj", Resources.ProjectFiles.CSharp.WithXaml)
- .WithFile(@"CSharpProject\App.xaml", Resources.SourceFiles.Xaml.App)
- .WithFile(@"CSharpProject\App.xaml.cs", Resources.SourceFiles.CSharp.App)
- .WithFile(@"CSharpProject\MainWindow.xaml", Resources.SourceFiles.Xaml.MainWindow)
- .WithFile(@"CSharpProject\MainWindow.xaml.cs", Resources.SourceFiles.CSharp.MainWindow));
- var projectFilePath = GetSolutionFileName(@"CSharpProject\CSharpProject.csproj");
-
- // Ensure the Xaml compiler does not run in a separate appdomain. It appears that this won't work within xUnit.
- using var workspace = CreateMSBuildWorkspace(("AlwaysCompileMarkupFilesInSeparateDomain", "false"));
- var project = await workspace.OpenProjectAsync(projectFilePath);
- var documents = project.Documents.ToList();
-
- // AssemblyInfo.cs, App.xaml.cs, MainWindow.xaml.cs, App.g.cs, MainWindow.g.cs, + unusual AssemblyAttributes.cs
- Assert.Equal(6, documents.Count);
-
- // both xaml code behind files are documents
- Assert.Contains(documents, d => d.Name == "App.xaml.cs");
- Assert.Contains(documents, d => d.Name == "MainWindow.xaml.cs");
-
- // prove no xaml files are documents
- Assert.DoesNotContain(documents, d => d.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase));
-
- // prove that generated source files for xaml files are included in documents list
- Assert.Contains(documents, d => d.Name == "App.g.cs");
- Assert.Contains(documents, d => d.Name == "MainWindow.g.cs");
- }
-
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestMetadataReferenceHasBadHintPath()
{
// prove that even with bad hint path for metadata reference the workspace can succeed at finding the correct metadata reference.
@@ -753,7 +722,7 @@ public async Task TestMetadataReferenceHasBadHintPath()
Assert.NotNull(csharpLib);
}
- [ConditionalFact(typeof(VisualStudio16_9_Preview3OrHigherMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuild16_9OrHigherInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(531631, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531631")]
public async Task TestOpenProject_AssemblyNameIsPath()
{
@@ -772,7 +741,7 @@ public async Task TestOpenProject_AssemblyNameIsPath()
Assert.Equal(expectedOutputPath, Path.GetDirectoryName(project.OutputFilePath));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(531631, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531631")]
public async Task TestOpenProject_AssemblyNameIsPath2()
{
@@ -790,7 +759,7 @@ public async Task TestOpenProject_AssemblyNameIsPath2()
Assert.Equal(expectedOutputPath, Path.GetDirectoryName(Path.GetFullPath(project.OutputFilePath)));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithDuplicateFile()
{
// Verify that we don't throw in this case
@@ -806,7 +775,7 @@ public async Task TestOpenProject_WithDuplicateFile()
Assert.Equal(2, documents.Count);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithInvalidFileExtensionAsync()
{
// make sure the file does in fact exist, but with an unrecognized extension
@@ -823,7 +792,7 @@ public async Task TestOpenProject_WithInvalidFileExtensionAsync()
Assert.Equal(expected, e.Message);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_ProjectFileExtensionAssociatedWithUnknownLanguageAsync()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -841,7 +810,7 @@ public async Task TestOpenProject_ProjectFileExtensionAssociatedWithUnknownLangu
Assert.Equal(expected, e.Message);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithAssociatedLanguageExtension1()
{
// make a CSharp solution with a project file having the incorrect extension 'vbproj', and then load it using the overload the lets us
@@ -859,7 +828,7 @@ public async Task TestOpenProject_WithAssociatedLanguageExtension1()
Assert.Empty(diagnostics);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithAssociatedLanguageExtension2_IgnoreCase()
{
// make a CSharp solution with a project file having the incorrect extension 'anyproj', and then load it using the overload the lets us
@@ -878,7 +847,7 @@ public async Task TestOpenProject_WithAssociatedLanguageExtension2_IgnoreCase()
Assert.Empty(diagnostics);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_WithNonExistentSolutionFile_FailsAsync()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -891,20 +860,21 @@ await Assert.ThrowsAsync(async () =>
});
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_WithInvalidSolutionFile_FailsAsync()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
var solutionFilePath = GetSolutionFileName(@"http://localhost/Invalid/InvalidSolution.sln");
+ using var workspace = CreateMSBuildWorkspace();
- await Assert.ThrowsAsync(async () =>
- {
- using var workspace = CreateMSBuildWorkspace();
- await workspace.OpenSolutionAsync(solutionFilePath);
- });
+#if NETCOREAPP
+ await Assert.ThrowsAsync(() => workspace.OpenSolutionAsync(solutionFilePath));
+#else
+ await Assert.ThrowsAsync(() => workspace.OpenSolutionAsync(solutionFilePath));
+#endif
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_WithTemporaryLockedFile_SucceedsWithoutFailureEvent()
{
// when skipped we should see a diagnostic for the invalid project
@@ -939,7 +909,7 @@ public async Task TestOpenSolution_WithTemporaryLockedFile_SucceedsWithoutFailur
Assert.Empty(ws.Diagnostics);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_WithLockedFile_FailsWithFailureEvent()
{
// when skipped we should see a diagnostic for the invalid project
@@ -966,7 +936,7 @@ public async Task TestOpenSolution_WithLockedFile_FailsWithFailureEvent()
Assert.Equal(WorkspaceDiagnosticKind.Failure, workspace.Diagnostics.Single().Kind);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_WithInvalidProjectPath_SkipTrue_SucceedsWithFailureEvent()
{
// when skipped we should see a diagnostic for the invalid project
@@ -982,7 +952,7 @@ public async Task TestOpenSolution_WithInvalidProjectPath_SkipTrue_SucceedsWithF
}
[WorkItem(985906, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/985906")]
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task HandleSolutionProjectTypeSolutionFolder()
{
CreateFiles(GetSimpleCSharpSolutionFiles()
@@ -994,7 +964,7 @@ public async Task HandleSolutionProjectTypeSolutionFolder()
Assert.Empty(workspace.Diagnostics);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_WithInvalidProjectPath_SkipFalse_Fails()
{
// when not skipped we should get an exception for the invalid project
@@ -1006,10 +976,14 @@ public async Task TestOpenSolution_WithInvalidProjectPath_SkipFalse_Fails()
using var workspace = CreateMSBuildWorkspace();
workspace.SkipUnrecognizedProjects = false;
+#if NETCOREAPP
+ await Assert.ThrowsAsync(() => workspace.OpenSolutionAsync(solutionFilePath));
+#else
await Assert.ThrowsAsync(() => workspace.OpenSolutionAsync(solutionFilePath));
+#endif
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_WithNonExistentProject_SkipTrue_SucceedsWithFailureEvent()
{
// when skipped we should see a diagnostic for the non-existent project
@@ -1024,7 +998,7 @@ public async Task TestOpenSolution_WithNonExistentProject_SkipTrue_SucceedsWithF
Assert.Single(workspace.Diagnostics);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_WithNonExistentProject_SkipFalse_Fails()
{
// when skipped we should see an exception for the non-existent project
@@ -1039,7 +1013,7 @@ public async Task TestOpenSolution_WithNonExistentProject_SkipFalse_Fails()
await Assert.ThrowsAsync(() => workspace.OpenSolutionAsync(solutionFilePath));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_WithUnrecognizedProjectFileExtension_Fails()
{
// proves that for solution open, project type guid and extension are both necessary
@@ -1053,7 +1027,7 @@ public async Task TestOpenSolution_WithUnrecognizedProjectFileExtension_Fails()
Assert.Empty(solution.ProjectIds);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_WithUnrecognizedProjectTypeGuidButRecognizedExtension_Succeeds()
{
// proves that if project type guid is not recognized, a known project file extension is all we need.
@@ -1066,7 +1040,7 @@ public async Task TestOpenSolution_WithUnrecognizedProjectTypeGuidButRecognizedE
Assert.Single(solution.ProjectIds);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_WithUnrecognizedProjectTypeGuidAndUnrecognizedExtension_WithSkipTrue_SucceedsWithFailureEvent()
{
// proves that if both project type guid and file extension are unrecognized, then project is skipped.
@@ -1083,7 +1057,7 @@ public async Task TestOpenSolution_WithUnrecognizedProjectTypeGuidAndUnrecognize
Assert.Empty(solution.ProjectIds);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_WithUnrecognizedProjectTypeGuidAndUnrecognizedExtension_WithSkipFalse_FailsAsync()
{
// proves that if both project type guid and file extension are unrecognized, then open project fails.
@@ -1108,7 +1082,7 @@ public async Task TestOpenSolution_WithUnrecognizedProjectTypeGuidAndUnrecognize
private readonly IEnumerable _defaultAssembliesWithoutCSharp = MefHostServices.DefaultAssemblies.Where(a => !a.FullName.Contains("CSharp"));
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(3931, "https://github.com/dotnet/roslyn/issues/3931")]
public async Task TestOpenSolution_WithMissingLanguageLibraries_WithSkipFalse_ThrowsAsync()
{
@@ -1128,7 +1102,7 @@ public async Task TestOpenSolution_WithMissingLanguageLibraries_WithSkipFalse_Th
Assert.Equal(expected, e.Message);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(3931, "https://github.com/dotnet/roslyn/issues/3931")]
public async Task TestOpenSolution_WithMissingLanguageLibraries_WithSkipTrue_SucceedsWithDiagnostic()
{
@@ -1146,7 +1120,7 @@ public async Task TestOpenSolution_WithMissingLanguageLibraries_WithSkipTrue_Suc
Assert.Equal(expected, workspace.Diagnostics.Single().Message);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(3931, "https://github.com/dotnet/roslyn/issues/3931")]
public async Task TestOpenProject_WithMissingLanguageLibraries_Throws()
{
@@ -1161,20 +1135,22 @@ public async Task TestOpenProject_WithMissingLanguageLibraries_Throws()
Assert.Equal(expected, e.Message);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithInvalidFilePath_Fails()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
var projectFilePath = GetSolutionFileName(@"http://localhost/Invalid/InvalidProject.csproj");
- await Assert.ThrowsAsync(async () =>
- {
- using var workspace = CreateMSBuildWorkspace();
- await workspace.OpenProjectAsync(projectFilePath);
- });
+ using var workspace = CreateMSBuildWorkspace();
+
+#if NETCOREAPP
+ await Assert.ThrowsAsync(() => workspace.OpenProjectAsync(projectFilePath));
+#else
+ await Assert.ThrowsAsync(() => workspace.OpenProjectAsync(projectFilePath));
+#endif
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithNonExistentProjectFile_FailsAsync()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -1187,7 +1163,7 @@ await Assert.ThrowsAsync(async () =>
});
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithInvalidProjectReference_SkipTrue_SucceedsWithEvent()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -1204,22 +1180,24 @@ public async Task TestOpenProject_WithInvalidProjectReference_SkipTrue_SucceedsW
Assert.NotEmpty(workspace.Diagnostics);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithInvalidProjectReference_SkipFalse_Fails()
{
CreateFiles(GetMultiProjectSolutionFiles()
.WithFile(@"VisualBasicProject\VisualBasicProject.vbproj", Resources.ProjectFiles.VisualBasic.InvalidProjectReference));
var projectFilePath = GetSolutionFileName(@"VisualBasicProject\VisualBasicProject.vbproj");
- await Assert.ThrowsAsync(async () =>
- {
- using var workspace = CreateMSBuildWorkspace();
- workspace.SkipUnrecognizedProjects = false;
- await workspace.OpenProjectAsync(projectFilePath);
- });
+ using var workspace = CreateMSBuildWorkspace();
+ workspace.SkipUnrecognizedProjects = false;
+
+#if NETCOREAPP
+ await Assert.ThrowsAsync(() => workspace.OpenProjectAsync(projectFilePath));
+#else
+ await Assert.ThrowsAsync(() => workspace.OpenProjectAsync(projectFilePath));
+#endif
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithNonExistentProjectReference_SkipTrue_SucceedsWithEvent()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -1236,7 +1214,7 @@ public async Task TestOpenProject_WithNonExistentProjectReference_SkipTrue_Succe
Assert.NotEmpty(workspace.Diagnostics);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithNonExistentProjectReference_SkipFalse_FailsAsync()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -1251,7 +1229,7 @@ await Assert.ThrowsAsync(async () =>
});
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithUnrecognizedProjectReferenceFileExtension_SkipTrue_SucceedsWithEvent()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -1269,7 +1247,7 @@ public async Task TestOpenProject_WithUnrecognizedProjectReferenceFileExtension_
Assert.NotEmpty(workspace.Diagnostics);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithUnrecognizedProjectReferenceFileExtension_SkipFalse_Fails()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -1285,7 +1263,7 @@ await Assert.ThrowsAsync(async () =>
});
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithUnrecognizedProjectReferenceFileExtension_WithMetadata_SkipTrue_SucceedsByLoadingMetadata()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -1308,7 +1286,7 @@ public async Task TestOpenProject_WithUnrecognizedProjectReferenceFileExtension_
Assert.Contains(metaRefs, r => r is PortableExecutableReference reference && reference.Display.Contains("CSharpProject.dll"));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithUnrecognizedProjectReferenceFileExtension_WithMetadata_SkipFalse_SucceedsByLoadingMetadata()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -1330,7 +1308,7 @@ public async Task TestOpenProject_WithUnrecognizedProjectReferenceFileExtension_
Assert.Contains(project.MetadataReferences, r => r is PortableExecutableReference reference && reference.Display.Contains("CSharpProject.dll"));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithUnrecognizedProjectReferenceFileExtension_BadMsbuildProject_SkipTrue_SucceedsWithDanglingProjectReference()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -1354,7 +1332,7 @@ public async Task TestOpenProject_WithUnrecognizedProjectReferenceFileExtension_
Assert.InRange(workspace.Diagnostics.Count, 2, 3);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithReferencedProject_LoadMetadata_ExistingMetadata_Succeeds()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -1376,7 +1354,7 @@ public async Task TestOpenProject_WithReferencedProject_LoadMetadata_ExistingMet
Assert.Contains(metaRefs, r => r is PortableExecutableReference reference && reference.Display.Contains("CSharpProject.dll"));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WithReferencedProject_LoadMetadata_NonExistentMetadata_LoadsProjectInstead()
{
CreateFiles(GetMultiProjectSolutionFiles());
@@ -1396,7 +1374,7 @@ public async Task TestOpenProject_WithReferencedProject_LoadMetadata_NonExistent
Assert.DoesNotContain(metaRefs, r => r.Properties.Aliases.Contains("CSharpProject"));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_UpdateExistingReferences()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -1425,7 +1403,7 @@ public async Task TestOpenProject_UpdateExistingReferences()
Assert.DoesNotContain(vbProject.MetadataReferences, r => r.Properties.Aliases.Contains("CSharpProject"));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled), typeof(Framework35Installed))]
+ [ConditionalFact(typeof(MSBuildInstalled), typeof(Framework35Installed))]
[Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(528984, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/528984")]
public async Task TestOpenProject_AddVBDefaultReferences()
@@ -1447,182 +1425,182 @@ public async Task TestOpenProject_AddVBDefaultReferences()
var diagnostics = compilation.GetDiagnostics();
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_DebugType_Full()
{
CreateCSharpFilesWith("DebugType", "full");
await AssertCSParseOptionsAsync(0, options => options.Errors.Length);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_DebugType_None()
{
CreateCSharpFilesWith("DebugType", "none");
await AssertCSParseOptionsAsync(0, options => options.Errors.Length);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_DebugType_PDBOnly()
{
CreateCSharpFilesWith("DebugType", "pdbonly");
await AssertCSParseOptionsAsync(0, options => options.Errors.Length);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_DebugType_Portable()
{
CreateCSharpFilesWith("DebugType", "portable");
await AssertCSParseOptionsAsync(0, options => options.Errors.Length);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_DebugType_Embedded()
{
CreateCSharpFilesWith("DebugType", "embedded");
await AssertCSParseOptionsAsync(0, options => options.Errors.Length);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_OutputKind_DynamicallyLinkedLibrary()
{
CreateCSharpFilesWith("OutputType", "Library");
await AssertCSCompilationOptionsAsync(OutputKind.DynamicallyLinkedLibrary, options => options.OutputKind);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_OutputKind_ConsoleApplication()
{
CreateCSharpFilesWith("OutputType", "Exe");
await AssertCSCompilationOptionsAsync(OutputKind.ConsoleApplication, options => options.OutputKind);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_OutputKind_WindowsApplication()
{
CreateCSharpFilesWith("OutputType", "WinExe");
await AssertCSCompilationOptionsAsync(OutputKind.WindowsApplication, options => options.OutputKind);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_OutputKind_NetModule()
{
CreateCSharpFilesWith("OutputType", "Module");
await AssertCSCompilationOptionsAsync(OutputKind.NetModule, options => options.OutputKind);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_OptimizationLevel_Release()
{
CreateCSharpFilesWith("Optimize", "True");
await AssertCSCompilationOptionsAsync(OptimizationLevel.Release, options => options.OptimizationLevel);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_OptimizationLevel_Debug()
{
CreateCSharpFilesWith("Optimize", "False");
await AssertCSCompilationOptionsAsync(OptimizationLevel.Debug, options => options.OptimizationLevel);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_MainFileName()
{
CreateCSharpFilesWith("StartupObject", "Foo");
await AssertCSCompilationOptionsAsync("Foo", options => options.MainTypeName);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_AssemblyOriginatorKeyFile_SignAssembly_Missing()
{
CreateCSharpFiles();
await AssertCSCompilationOptionsAsync(null, options => options.CryptoKeyFile);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_AssemblyOriginatorKeyFile_SignAssembly_False()
{
CreateCSharpFilesWith("SignAssembly", "false");
await AssertCSCompilationOptionsAsync(null, options => options.CryptoKeyFile);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_AssemblyOriginatorKeyFile_SignAssembly_True()
{
CreateCSharpFilesWith("SignAssembly", "true");
await AssertCSCompilationOptionsAsync("snKey.snk", options => Path.GetFileName(options.CryptoKeyFile));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_AssemblyOriginatorKeyFile_DelaySign_False()
{
CreateCSharpFilesWith("DelaySign", "false");
await AssertCSCompilationOptionsAsync(null, options => options.DelaySign);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_AssemblyOriginatorKeyFile_DelaySign_True()
{
CreateCSharpFilesWith("DelaySign", "true");
await AssertCSCompilationOptionsAsync(true, options => options.DelaySign);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_CheckOverflow_True()
{
CreateCSharpFilesWith("CheckForOverflowUnderflow", "true");
await AssertCSCompilationOptionsAsync(true, options => options.CheckOverflow);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_CSharp_CheckOverflow_False()
{
CreateCSharpFilesWith("CheckForOverflowUnderflow", "false");
await AssertCSCompilationOptionsAsync(false, options => options.CheckOverflow);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestParseOptions_CSharp_Compatibility_ECMA1()
{
CreateCSharpFilesWith("LangVersion", "ISO-1");
await AssertCSParseOptionsAsync(CS.LanguageVersion.CSharp1, options => options.LanguageVersion);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestParseOptions_CSharp_Compatibility_ECMA2()
{
CreateCSharpFilesWith("LangVersion", "ISO-2");
await AssertCSParseOptionsAsync(CS.LanguageVersion.CSharp2, options => options.LanguageVersion);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestParseOptions_CSharp_Compatibility_None()
{
CreateCSharpFilesWith("LangVersion", "3");
await AssertCSParseOptionsAsync(CS.LanguageVersion.CSharp3, options => options.LanguageVersion);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled), AlwaysSkip = "https://github.com/dotnet/roslyn/issues/38301"), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled), AlwaysSkip = "https://github.com/dotnet/roslyn/issues/38301"), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestParseOptions_CSharp_LanguageVersion_Default()
{
CreateCSharpFiles();
await AssertCSParseOptionsAsync(CS.LanguageVersion.Default.MapSpecifiedToEffectiveVersion(), options => options.LanguageVersion);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestParseOptions_CSharp_PreprocessorSymbols()
{
CreateCSharpFilesWith("DefineConstants", "DEBUG;TRACE;X;Y");
await AssertCSParseOptionsAsync("DEBUG,TRACE,X,Y", options => string.Join(",", options.PreprocessorSymbolNames));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestConfigurationDebug()
{
CreateCSharpFiles();
await AssertCSParseOptionsAsync("DEBUG,TRACE", options => string.Join(",", options.PreprocessorSymbolNames));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestConfigurationRelease()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -1637,42 +1615,42 @@ public async Task TestConfigurationRelease()
Assert.Contains(options.PreprocessorSymbolNames, name => name == "TRACE");
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_DebugType_Full()
{
CreateVBFilesWith("DebugType", "full");
await AssertVBParseOptionsAsync(0, options => options.Errors.Length);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_DebugType_None()
{
CreateVBFilesWith("DebugType", "none");
await AssertVBParseOptionsAsync(0, options => options.Errors.Length);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_DebugType_PDBOnly()
{
CreateVBFilesWith("DebugType", "pdbonly");
await AssertVBParseOptionsAsync(0, options => options.Errors.Length);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_DebugType_Portable()
{
CreateVBFilesWith("DebugType", "portable");
await AssertVBParseOptionsAsync(0, options => options.Errors.Length);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_DebugType_Embedded()
{
CreateVBFilesWith("DebugType", "embedded");
await AssertVBParseOptionsAsync(0, options => options.Errors.Length);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_VBRuntime_Embed()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -1680,49 +1658,49 @@ public async Task TestCompilationOptions_VisualBasic_VBRuntime_Embed()
await AssertVBCompilationOptionsAsync(true, options => options.EmbedVbCoreRuntime);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OutputKind_DynamicallyLinkedLibrary()
{
CreateVBFilesWith("OutputType", "Library");
await AssertVBCompilationOptionsAsync(OutputKind.DynamicallyLinkedLibrary, options => options.OutputKind);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OutputKind_ConsoleApplication()
{
CreateVBFilesWith("OutputType", "Exe");
await AssertVBCompilationOptionsAsync(OutputKind.ConsoleApplication, options => options.OutputKind);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OutputKind_WindowsApplication()
{
CreateVBFilesWith("OutputType", "WinExe");
await AssertVBCompilationOptionsAsync(OutputKind.WindowsApplication, options => options.OutputKind);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OutputKind_NetModule()
{
CreateVBFilesWith("OutputType", "Module");
await AssertVBCompilationOptionsAsync(OutputKind.NetModule, options => options.OutputKind);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_RootNamespace()
{
CreateVBFilesWith("RootNamespace", "Foo.Bar");
await AssertVBCompilationOptionsAsync("Foo.Bar", options => options.RootNamespace);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OptionStrict_On()
{
CreateVBFilesWith("OptionStrict", "On");
await AssertVBCompilationOptionsAsync(VB.OptionStrict.On, options => options.OptionStrict);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OptionStrict_Off()
{
CreateVBFilesWith("OptionStrict", "Off");
@@ -1733,77 +1711,77 @@ public async Task TestCompilationOptions_VisualBasic_OptionStrict_Off()
await AssertVBCompilationOptionsAsync(VB.OptionStrict.Custom, options => options.OptionStrict);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OptionStrict_Custom()
{
CreateVBFilesWith("OptionStrictType", "Custom");
await AssertVBCompilationOptionsAsync(VB.OptionStrict.Custom, options => options.OptionStrict);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OptionInfer_True()
{
CreateVBFilesWith("OptionInfer", "On");
await AssertVBCompilationOptionsAsync(true, options => options.OptionInfer);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OptionInfer_False()
{
CreateVBFilesWith("OptionInfer", "Off");
await AssertVBCompilationOptionsAsync(false, options => options.OptionInfer);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OptionExplicit_True()
{
CreateVBFilesWith("OptionExplicit", "On");
await AssertVBCompilationOptionsAsync(true, options => options.OptionExplicit);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OptionExplicit_False()
{
CreateVBFilesWith("OptionExplicit", "Off");
await AssertVBCompilationOptionsAsync(false, options => options.OptionExplicit);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OptionCompareText_True()
{
CreateVBFilesWith("OptionCompare", "Text");
await AssertVBCompilationOptionsAsync(true, options => options.OptionCompareText);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OptionCompareText_False()
{
CreateVBFilesWith("OptionCompare", "Binary");
await AssertVBCompilationOptionsAsync(false, options => options.OptionCompareText);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OptionRemoveIntegerOverflowChecks_True()
{
CreateVBFilesWith("RemoveIntegerChecks", "true");
await AssertVBCompilationOptionsAsync(false, options => options.CheckOverflow);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OptionRemoveIntegerOverflowChecks_False()
{
CreateVBFilesWith("RemoveIntegerChecks", "false");
await AssertVBCompilationOptionsAsync(true, options => options.CheckOverflow);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_OptionAssemblyOriginatorKeyFile_SignAssemblyFalse()
{
CreateVBFilesWith("SignAssembly", "false");
await AssertVBCompilationOptionsAsync(null, options => options.CryptoKeyFile);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestCompilationOptions_VisualBasic_GlobalImports()
{
CreateFiles(GetMultiProjectSolutionFiles());
@@ -1828,7 +1806,7 @@ public async Task TestCompilationOptions_VisualBasic_GlobalImports()
actual: imports.Select(i => i.Name));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestParseOptions_VisualBasic_PreprocessorSymbols()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -1861,7 +1839,7 @@ public async Task TestParseOptions_VisualBasic_PreprocessorSymbols()
actual: defines);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task Test_VisualBasic_ConditionalAttributeEmitted()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -1885,7 +1863,7 @@ public async Task Test_VisualBasic_ConditionalAttributeEmitted()
Assert.Contains(attrs, ad => ad.AttributeClass.Name == "MyAttribute");
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task Test_VisualBasic_ConditionalAttributeNotEmitted()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -1908,7 +1886,7 @@ public async Task Test_VisualBasic_ConditionalAttributeNotEmitted()
Assert.DoesNotContain(attrs, ad => ad.AttributeClass.Name == "MyAttribute");
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task Test_CSharp_ConditionalAttributeEmitted()
{
CreateFiles(GetSimpleCSharpSolutionFiles()
@@ -1932,7 +1910,7 @@ public async Task Test_CSharp_ConditionalAttributeEmitted()
Assert.Contains(attrs, ad => ad.AttributeClass.Name == "MyAttr");
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task Test_CSharp_ConditionalAttributeNotEmitted()
{
CreateFiles(GetSimpleCSharpSolutionFiles()
@@ -1955,7 +1933,7 @@ public async Task Test_CSharp_ConditionalAttributeNotEmitted()
Assert.DoesNotContain(attrs, ad => ad.AttributeClass.Name == "MyAttr");
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_CSharp_WithLinkedDocument()
{
CreateFiles(GetSimpleCSharpSolutionFiles()
@@ -1979,7 +1957,7 @@ public async Task TestOpenProject_CSharp_WithLinkedDocument()
Assert.Equal(Resources.SourceFiles.CSharp.OtherStuff_Foo, text);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestAddDocumentAsync()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -2020,7 +1998,7 @@ public async Task TestAddDocumentAsync()
Assert.Single(documentB.Folders);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestUpdateDocumentAsync()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -2054,7 +2032,7 @@ public async Task TestUpdateDocumentAsync()
Assert.Equal(originalText.ToString(), text.ToString());
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestRemoveDocumentAsync()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -2081,7 +2059,7 @@ public async Task TestRemoveDocumentAsync()
Assert.Equal(originalText.ToString(), text.ToString());
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestApplyChanges_UpdateDocumentText()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -2108,7 +2086,7 @@ public async Task TestApplyChanges_UpdateDocumentText()
Assert.Equal(newText.ToString(), textOnDisk);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestApplyChanges_UpdateAdditionalDocumentText()
{
CreateFiles(GetSimpleCSharpSolutionWithAdditionaFile());
@@ -2135,7 +2113,7 @@ public async Task TestApplyChanges_UpdateAdditionalDocumentText()
Assert.Equal(newText.ToString(), textOnDisk);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestApplyChanges_AddDocument()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -2161,7 +2139,7 @@ public async Task TestApplyChanges_AddDocument()
Assert.Equal(newText.ToString(), textOnDisk);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestApplyChanges_NotSupportedChangesFail()
{
var csharpProjPath = @"AnalyzerSolution\CSharpProject_AnalyzerReference.csproj";
@@ -2195,7 +2173,7 @@ public async Task TestApplyChanges_NotSupportedChangesFail()
});
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestWorkspaceChangedEvent()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -2225,7 +2203,7 @@ public async Task TestWorkspaceChangedEvent()
AsyncEventTimeout));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestWorkspaceChangedWeakEvent()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -2261,7 +2239,7 @@ public async Task TestWorkspaceChangedWeakEvent()
AsyncEventTimeout));
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(529276, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529276"), WorkItem(12086, "DevDiv_Projects/Roslyn")]
public async Task TestOpenProject_LoadMetadataForReferenceProjects_NoMetadata()
{
@@ -2286,7 +2264,7 @@ public async Task TestOpenProject_LoadMetadataForReferenceProjects_NoMetadata()
Assert.Empty(errs);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(918072, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/918072")]
public async Task TestAnalyzerReferenceLoadStandalone()
{
@@ -2311,7 +2289,7 @@ public async Task TestAnalyzerReferenceLoadStandalone()
Assert.Equal(2, workspace.CurrentSolution.Projects.Count());
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestAdditionalFilesStandalone()
{
var projPaths = new[] { @"AnalyzerSolution\CSharpProject_AnalyzerReference.csproj", @"AnalyzerSolution\VisualBasicProject_AnalyzerReference.vbproj" };
@@ -2332,7 +2310,7 @@ public async Task TestAdditionalFilesStandalone()
}
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestLoadTextSync()
{
var files = GetAnalyzerReferenceSolutionFiles();
@@ -2353,7 +2331,7 @@ public async Task TestLoadTextSync()
Assert.Contains("Window", atav.Text.ToString(), StringComparison.Ordinal);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestGetTextSynchronously()
{
var files = GetAnalyzerReferenceSolutionFiles();
@@ -2372,7 +2350,7 @@ public async Task TestGetTextSynchronously()
Assert.Contains("Window", atext.ToString(), StringComparison.Ordinal);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(546171, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546171")]
public async Task TestCSharpExternAlias()
{
@@ -2390,7 +2368,7 @@ public async Task TestCSharpExternAlias()
comp.GetDiagnostics().Where(d => d.Severity > DiagnosticSeverity.Info).Verify();
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(530337, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530337")]
public async Task TestProjectReferenceWithExternAlias()
{
@@ -2406,7 +2384,7 @@ public async Task TestProjectReferenceWithExternAlias()
comp.GetDiagnostics().Where(d => d.Severity > DiagnosticSeverity.Info).Verify();
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestProjectReferenceWithReferenceOutputAssemblyFalse()
{
var files = GetProjectReferenceSolutionFiles();
@@ -2455,7 +2433,7 @@ private static string VisitProjectReferences(string projectFileText, Action(async () =>
});
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_WithNonExistentSolutionFileAsync()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -2599,7 +2577,7 @@ await Assert.ThrowsAsync(async () =>
});
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_SolutionFileHasEmptyLinesAndWhitespaceOnlyLines()
{
var files = new FileSet(
@@ -2616,7 +2594,7 @@ public async Task TestOpenSolution_SolutionFileHasEmptyLinesAndWhitespaceOnlyLin
var project = solution.Projects.First();
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(531543, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531543")]
public async Task TestOpenSolution_SolutionFileHasEmptyLineBetweenProjectBlock()
{
@@ -2630,7 +2608,7 @@ public async Task TestOpenSolution_SolutionFileHasEmptyLineBetweenProjectBlock()
var solution = await workspace.OpenSolutionAsync(solutionFilePath);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled), AlwaysSkip = "MSBuild parsing API throws InvalidProjectFileException")]
+ [ConditionalFact(typeof(MSBuildInstalled), AlwaysSkip = "MSBuild parsing API throws InvalidProjectFileException")]
[Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(531283, "DevDiv")]
public async Task TestOpenSolution_SolutionFileHasMissingEndProject()
@@ -2661,7 +2639,7 @@ public async Task TestOpenSolution_SolutionFileHasMissingEndProject()
}
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(792912, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/792912")]
public async Task TestOpenSolution_WithDuplicatedGuidsBecomeSelfReferential()
{
@@ -2686,7 +2664,7 @@ public async Task TestOpenSolution_WithDuplicatedGuidsBecomeSelfReferential()
Assert.Empty(libraryProject.AllProjectReferences);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(792912, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/792912")]
public async Task TestOpenSolution_WithDuplicatedGuidsBecomeCircularReferential()
{
@@ -2716,7 +2694,7 @@ public async Task TestOpenSolution_WithDuplicatedGuidsBecomeCircularReferential(
Assert.Empty(library2Project.AllProjectReferences);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_CSharp_WithMissingDebugType()
{
CreateFiles(new FileSet(
@@ -2728,31 +2706,7 @@ public async Task TestOpenProject_CSharp_WithMissingDebugType()
await workspace.OpenSolutionAsync(solutionFilePath);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
- [WorkItem(991528, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991528")]
- public async Task MSBuildProjectShouldHandleCodePageProperty()
- {
- var files = new FileSet(
- ("Encoding.csproj", Resources.ProjectFiles.CSharp.Encoding.Replace("ReplaceMe", "1254")),
- ("class1.cs", "//\u201C"));
-
- CreateFiles(files);
-
- var projPath = GetSolutionFileName("Encoding.csproj");
- using var workspace = CreateMSBuildWorkspace();
- var project = await workspace.OpenProjectAsync(projPath);
- var document = project.Documents.First(d => d.Name == "class1.cs");
- var text = await document.GetTextAsync();
- Assert.Equal(Encoding.GetEncoding(1254), text.Encoding);
-
- // The smart quote (“) in class1.cs shows up as "“" in codepage 1254. Do a sanity
- // check here to make sure this file hasn't been corrupted in a way that would
- // impact subsequent asserts.
- Assert.Equal(5, "//\u00E2\u20AC\u0153".Length);
- Assert.Equal("//\u00E2\u20AC\u0153".Length, text.Length);
- }
-
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(991528, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991528")]
public async Task MSBuildProjectShouldHandleInvalidCodePageProperty()
{
@@ -2771,7 +2725,7 @@ public async Task MSBuildProjectShouldHandleInvalidCodePageProperty()
Assert.Equal(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true), text.Encoding);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(991528, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991528")]
public async Task MSBuildProjectShouldHandleInvalidCodePageProperty2()
{
@@ -2790,7 +2744,7 @@ public async Task MSBuildProjectShouldHandleInvalidCodePageProperty2()
Assert.Equal(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true), text.Encoding);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(991528, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991528")]
public async Task MSBuildProjectShouldHandleDefaultCodePageProperty()
{
@@ -2810,7 +2764,7 @@ public async Task MSBuildProjectShouldHandleDefaultCodePageProperty()
Assert.Equal("//\u201C", text.ToString());
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(981208, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/981208")]
[WorkItem(28639, "https://github.com/dotnet/roslyn/issues/28639")]
public void DisposeMSBuildWorkspaceAndServicesCollected()
@@ -2840,7 +2794,7 @@ public void DisposeMSBuildWorkspaceAndServicesCollected()
sol.AssertReleased();
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(1088127, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1088127")]
public async Task MSBuildWorkspacePreservesEncoding()
{
@@ -2899,98 +2853,7 @@ class C { }";
Assert.Equal(encoding.EncodingName, reloadedText.Encoding.EncodingName);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
- public async Task TestAddRemoveMetadataReference_GAC()
- {
- CreateFiles(GetSimpleCSharpSolutionFiles());
-
- var projFile = GetSolutionFileName(@"CSharpProject\CSharpProject.csproj");
- var projFileText = File.ReadAllText(projFile);
- Assert.False(projFileText.Contains(@"System.Xaml"));
-
- using var workspace = CreateMSBuildWorkspace();
- var solutionFilePath = GetSolutionFileName("TestSolution.sln");
- var solution = await workspace.OpenSolutionAsync(solutionFilePath);
- var project = solution.Projects.First();
-
- var mref = MetadataReference.CreateFromFile(typeof(System.Xaml.XamlObjectReader).Assembly.Location);
-
- // add reference to System.Xaml
- workspace.TryApplyChanges(project.AddMetadataReference(mref).Solution);
- projFileText = File.ReadAllText(projFile);
- Assert.Contains(@" p.Language == LanguageNames.CSharp);
- var vbProject = solution.Projects.First(p => p.Language == LanguageNames.VisualBasic);
-
- var numericsMetadata = csProject.MetadataReferences.Single(m => m.Display.Contains("System.Numerics"));
-
- // add reference to System.Xaml
- workspace.TryApplyChanges(vbProject.AddMetadataReference(numericsMetadata).Solution);
- var newVbProjFileText = File.ReadAllText(vbProjFile);
- Assert.Contains(@"..\References\MyAssembly.dll", projFileText);
-
- // remove reference MyAssembly.dll
- workspace.TryApplyChanges(workspace.CurrentSolution.GetProject(project.Id).RemoveMetadataReference(mref).Solution);
- projFileText = File.ReadAllText(projFile);
- Assert.DoesNotContain(@"..\References\MyAssembly.dll", projFileText);
- }
-
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestAddRemoveAnalyzerReference()
{
CreateFiles(GetSimpleCSharpSolutionFiles()
@@ -3019,7 +2882,7 @@ public async Task TestAddRemoveAnalyzerReference()
Assert.DoesNotContain(@"", projFileText);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(1101040, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1101040")]
public async Task TestOpenProject_BadLink()
{
@@ -3064,7 +2927,7 @@ public async Task TestOpenProject_BadLink()
Assert.Equal(3, docs.Count);
}
- [ConditionalFact(typeof(IsEnglishLocal), typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(IsEnglishLocal), typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_BadElement()
{
CreateFiles(GetSimpleCSharpSolutionFiles()
@@ -3081,7 +2944,7 @@ public async Task TestOpenProject_BadElement()
Assert.Empty(proj.DocumentIds);
}
- [ConditionalFact(typeof(IsEnglishLocal), typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(IsEnglishLocal), typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_BadTaskImport()
{
CreateFiles(GetSimpleCSharpSolutionFiles()
@@ -3098,7 +2961,7 @@ public async Task TestOpenProject_BadTaskImport()
Assert.Empty(proj.DocumentIds);
}
- [ConditionalFact(typeof(IsEnglishLocal), typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(IsEnglishLocal), typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenSolution_BadTaskImport()
{
CreateFiles(GetSimpleCSharpSolutionFiles()
@@ -3116,7 +2979,7 @@ public async Task TestOpenSolution_BadTaskImport()
Assert.Empty(project.DocumentIds);
}
- [ConditionalFact(typeof(IsEnglishLocal), typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(IsEnglishLocal), typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_MsbuildError()
{
CreateFiles(GetSimpleCSharpSolutionFiles()
@@ -3131,7 +2994,7 @@ public async Task TestOpenProject_MsbuildError()
Assert.StartsWith("Msbuild failed", diagnostic.Message);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_WildcardsWithLink()
{
CreateFiles(GetSimpleCSharpSolutionFiles()
@@ -3146,7 +3009,7 @@ public async Task TestOpenProject_WildcardsWithLink()
Assert.Contains(proj.Documents, d => d.Name == "AssemblyInfo.cs");
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestOpenProject_CommandLineArgsHaveNoErrors()
{
CreateFiles(GetSimpleCSharpSolutionFiles());
@@ -3179,7 +3042,7 @@ public async Task TestOpenProject_CommandLineArgsHaveNoErrors()
Assert.Empty(commandLineArgs.Errors);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(29122, "https://github.com/dotnet/roslyn/issues/29122")]
public async Task TestOpenSolution_ProjectReferencesWithUnconventionalOutputPaths()
{
@@ -3216,7 +3079,7 @@ public async Task TestOpenSolution_ProjectReferencesWithUnconventionalOutputPath
}
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(29494, "https://github.com/dotnet/roslyn/issues/29494")]
public async Task TestOpenProjectAsync_MalformedAdditionalFilePath()
{
@@ -3238,7 +3101,7 @@ public async Task TestOpenProjectAsync_MalformedAdditionalFilePath()
Assert.Contains(project.AdditionalDocuments, doc => doc.Name == "TEST::");
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[WorkItem(31390, "https://github.com/dotnet/roslyn/issues/31390")]
public async Task TestDuplicateProjectAndMetadataReferences()
{
@@ -3262,7 +3125,7 @@ public async Task TestDuplicateProjectAndMetadataReferences()
Assert.Single(compilation.References.OfType());
}
- [ConditionalFact(typeof(VisualStudio16_2OrHigherMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuild16_2OrHigherInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestEditorConfigDiscovery()
{
var files = GetSimpleCSharpSolutionFiles()
@@ -3286,7 +3149,7 @@ public async Task TestEditorConfigDiscovery()
Assert.Equal("root = true", text.ToString());
}
- [ConditionalFact(typeof(VisualStudio16_2OrHigherMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuild16_2OrHigherInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestEditorConfigDiscoveryDisabled()
{
var files = GetSimpleCSharpSolutionFiles()
@@ -3303,7 +3166,7 @@ public async Task TestEditorConfigDiscoveryDisabled()
Assert.Empty(project.AnalyzerConfigDocuments);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestSolutionFilterSupport()
{
CreateFiles(GetMultiProjectSolutionFiles()
@@ -3317,7 +3180,7 @@ public async Task TestSolutionFilterSupport()
Assert.Equal(LanguageNames.CSharp, csharpProject.Language);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [ConditionalFact(typeof(MSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
public async Task TestInvalidSolutionFilterDoesNotLoad()
{
CreateFiles(GetMultiProjectSolutionFiles()
diff --git a/src/Workspaces/MSBuildTest/Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests.csproj b/src/Workspaces/MSBuildTest/Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests.csproj
index 3d0c6e993c0ab..4903d07eb35c8 100644
--- a/src/Workspaces/MSBuildTest/Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests.csproj
+++ b/src/Workspaces/MSBuildTest/Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests.csproj
@@ -4,7 +4,7 @@
Library
Microsoft.CodeAnalysis.MSBuild.UnitTests
- net472
+ netcoreapp3.1;net472
@@ -26,12 +26,23 @@
-
+
+
+
+
+
+
+
+
+
-
+
false
diff --git a/src/Workspaces/MSBuildTest/NetCoreTests.cs b/src/Workspaces/MSBuildTest/NetCoreTests.cs
index 805a3018d0c8d..8e418ecac7af2 100644
--- a/src/Workspaces/MSBuildTest/NetCoreTests.cs
+++ b/src/Workspaces/MSBuildTest/NetCoreTests.cs
@@ -62,7 +62,7 @@ private void DotNetBuild(string solutionOrProjectFileName, string configuration
RunDotNet(arguments);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable))]
+ [ConditionalFact(typeof(MSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable))]
[Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[Trait(Traits.Feature, Traits.Features.NetCore)]
public async Task TestOpenProject_NetCoreApp2()
@@ -88,7 +88,7 @@ public async Task TestOpenProject_NetCoreApp2()
}
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable))]
+ [ConditionalFact(typeof(MSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable))]
[Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[Trait(Traits.Feature, Traits.Features.NetCore)]
public async Task TestOpenProjectTwice_NetCoreApp2AndLibrary()
@@ -125,7 +125,7 @@ public async Task TestOpenProjectTwice_NetCoreApp2AndLibrary()
Assert.Equal(libraryProject.FilePath, workspace.CurrentSolution.GetProject(projectRefId).FilePath);
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable))]
+ [ConditionalFact(typeof(MSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable))]
[Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[Trait(Traits.Feature, Traits.Features.NetCore)]
public async Task TestOpenProjectTwice_NetCoreApp2AndTwoLibraries()
@@ -173,7 +173,7 @@ static void AssertSingleProjectReference(Project project, string projectRefFileP
}
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable))]
+ [ConditionalFact(typeof(MSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable))]
[Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[Trait(Traits.Feature, Traits.Features.NetCore)]
public async Task TestOpenProject_NetCoreMultiTFM()
@@ -217,7 +217,7 @@ public async Task TestOpenProject_NetCoreMultiTFM()
}
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable))]
+ [ConditionalFact(typeof(MSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable))]
[Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[Trait(Traits.Feature, Traits.Features.NetCore)]
public async Task TestOpenProject_NetCoreMultiTFM_ExtensionWithConditionOnTFM()
@@ -261,7 +261,7 @@ public async Task TestOpenProject_NetCoreMultiTFM_ExtensionWithConditionOnTFM()
}
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable))]
+ [ConditionalFact(typeof(MSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable))]
[Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[Trait(Traits.Feature, Traits.Features.NetCore)]
public async Task TestOpenProject_NetCoreMultiTFM_ProjectReference()
@@ -369,7 +369,7 @@ private static async Task AssertNetCoreMultiTFMProject(string projectFilePath)
}
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable), AlwaysSkip = "https://github.com/dotnet/roslyn/issues/41917")]
+ [ConditionalFact(typeof(MSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable), AlwaysSkip = "https://github.com/dotnet/roslyn/issues/41917")]
[Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[Trait(Traits.Feature, Traits.Features.NetCore)]
public async Task TestOpenSolution_NetCoreMultiTFMWithProjectReferenceToFSharp()
@@ -429,7 +429,7 @@ public async Task TestOpenProject_ReferenceConfigurationSpecificMetadata()
}
}
- [ConditionalFact(typeof(VisualStudioMSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable))]
+ [ConditionalFact(typeof(MSBuildInstalled), typeof(DotNetCoreSdk.IsAvailable))]
[Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
[Trait(Traits.Feature, Traits.Features.NetCore)]
public async Task TestOpenProject_OverrideTFM()
diff --git a/src/Workspaces/MSBuildTest/VisualStudioMSBuildInstalled.cs b/src/Workspaces/MSBuildTest/VisualStudioMSBuildInstalled.cs
index 5baa4e5914ad9..5bc7afdf9e039 100644
--- a/src/Workspaces/MSBuildTest/VisualStudioMSBuildInstalled.cs
+++ b/src/Workspaces/MSBuildTest/VisualStudioMSBuildInstalled.cs
@@ -2,213 +2,47 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#nullable disable
-
using System;
-using System.Collections.Immutable;
-using System.IO;
using System.Linq;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using Microsoft.VisualStudio.Setup.Configuration;
+using Microsoft.Build.Locator;
using Roslyn.Test.Utilities;
namespace Microsoft.CodeAnalysis.MSBuild.UnitTests
{
internal class VisualStudioMSBuildInstalled : ExecutionCondition
{
- private static bool s_isRegistered;
-
- private readonly Version _minimumVersion;
-
- public VisualStudioMSBuildInstalled() : this(new Version(15, 0))
- {
+ private static readonly VisualStudioInstance? s_instance;
- }
- protected VisualStudioMSBuildInstalled(Version minimumVersion)
+ static VisualStudioMSBuildInstalled()
{
- _minimumVersion = minimumVersion;
- }
+ s_instance = MSBuildLocator.QueryVisualStudioInstances()
+ .OrderByDescending(instances => instances.Version)
+ .FirstOrDefault();
- public override bool ShouldSkip
- {
- get
+ if (s_instance != null && !MSBuildLocator.IsRegistered)
{
- if (VisualStudioMSBuildLocator.TryFindMSBuildToolsPath(out var versionAndPath))
- {
- if (versionAndPath.version < _minimumVersion)
- {
- return true;
- }
-
- if (!s_isRegistered)
- {
- RegisterMSBuildAssemblyResolution(versionAndPath.path);
-
- s_isRegistered = true;
- }
-
- return false;
- }
-
- return true;
+ MSBuildLocator.RegisterInstance(s_instance);
}
}
- public override string SkipReason => $"Could not locate Visual Studio with MSBuild {_minimumVersion} or higher installed";
-
- private static void RegisterMSBuildAssemblyResolution(string msbuildToolsPath)
- {
- if (s_isRegistered)
- {
- throw new InvalidOperationException("Attempted to register twice!");
- }
-
- var assemblyNames = new[]
- {
- "Microsoft.Build",
- "Microsoft.Build.Framework",
- "Microsoft.Build.Tasks.Core",
- "Microsoft.Build.Utilities.Core"
- };
-
- var builder = ImmutableDictionary.CreateBuilder(StringComparer.OrdinalIgnoreCase);
-
- foreach (var assemblyName in assemblyNames)
- {
- var assemblyFilePath = Path.Combine(msbuildToolsPath, assemblyName + ".dll");
- var assembly = File.Exists(assemblyFilePath)
- ? Assembly.LoadFrom(assemblyFilePath)
- : null;
-
- if (assembly != null)
- {
- builder.Add(assemblyName, assembly);
- }
- }
-
- var assemblyMap = builder.ToImmutable();
-
- AppDomain.CurrentDomain.AssemblyResolve += (_, e) =>
- {
- var assemblyName = new AssemblyName(e.Name);
-
- if (assemblyMap.TryGetValue(assemblyName.Name, out var assembly))
- {
- return assembly;
- }
-
- return null;
- };
- }
- }
-
- internal class VisualStudio16_2OrHigherMSBuildInstalled : VisualStudioMSBuildInstalled
- {
- public VisualStudio16_2OrHigherMSBuildInstalled() : base(new Version(16, 2))
- {
- }
- }
+ private readonly Version _minimumVersion;
- internal class VisualStudio16_9_Preview3OrHigherMSBuildInstalled : VisualStudioMSBuildInstalled
- {
- public VisualStudio16_9_Preview3OrHigherMSBuildInstalled() : base(new Version(16, 9, 30914, 41))
+ public VisualStudioMSBuildInstalled() : this(new Version(15, 0))
{
}
- }
-
- internal static class VisualStudioMSBuildLocator
- {
- private static readonly Lazy<(Version version, string path)> s_versionAndPath = new(FindMSBuildToolsPathFromVisualStudioCore);
- public static bool TryFindMSBuildToolsPath(out (Version version, string path) versionAndPath)
+ internal VisualStudioMSBuildInstalled(Version minimumVersion)
{
- versionAndPath = s_versionAndPath.Value;
- return versionAndPath.path != null;
+ _minimumVersion = minimumVersion;
}
- private static (Version version, string path) FindMSBuildToolsPathFromVisualStudioCore()
- {
- // Only on Windows
- if (Path.DirectorySeparatorChar != '\\')
- {
- return (null, null);
- }
+ public override bool ShouldSkip => s_instance is null || s_instance.Version < _minimumVersion;
- try
- {
- var configuration = Interop.GetSetupConfiguration();
- if (configuration == null)
- {
- return (null, null);
- }
-
- var instanceEnum = configuration.EnumAllInstances();
- var instances = new ISetupInstance[1];
-
- (Version version, string path) found = (null, null);
-
- while (true)
- {
- instanceEnum.Next(1, instances, out var fetched);
- if (fetched <= 0)
- {
- break;
- }
-
- var instance2 = (ISetupInstance2)instances[0];
- var state = instance2.GetState();
- if (state == InstanceState.Complete &&
- instance2.GetPackages().Any(package => package.GetId() == "Microsoft.VisualStudio.Component.Roslyn.Compiler"))
- {
- var instanceVersionString = instance2.GetInstallationVersion();
-
- if (!Version.TryParse(instanceVersionString, out var instanceVersion))
- {
- // We'll throw an exception here -- this means we have some build with a new style of version numbers, which is probably the high version we want to pick but
- // we won't know it
- throw new Exception($"Unable to parse version string '{instanceVersionString}'");
- }
-
- var toolsBasePath = Path.Combine(instance2.GetInstallationPath(), "MSBuild");
- string instanceMsBuildPath = null;
-
- // Visual Studio 2019 and later place MSBuild in a "Current" folder.
- var toolsPath = Path.Combine(toolsBasePath, "Current", "Bin");
- if (Directory.Exists(toolsPath))
- {
- instanceMsBuildPath = toolsPath;
- }
- else
- {
- // Check for 15.0 to support Visual Studio 2017. We have this in an else block because in 2019 there's also this folder for compat reasons
- toolsPath = Path.Combine(toolsBasePath, "15.0", "Bin");
- if (Directory.Exists(toolsPath))
- {
- instanceMsBuildPath = toolsPath;
- }
- }
-
- // We found some version; we will always use the highest possible version because we want to support the running of the most tests
- // possible -- we can't load multiple versions sanely unless we tried multiple AppDomains
- if (instanceMsBuildPath != null && (found.version == null || instanceVersion > found.version))
- {
- found.version = instanceVersion;
- found.path = instanceMsBuildPath;
- }
- }
- }
-
- return found;
- }
- catch (COMException)
- {
- return (null, null);
- }
- catch (DllNotFoundException)
- {
- return (null, null);
- }
- }
+ public override string SkipReason
+#if !NETCOREAPP
+ => $"Could not locate Visual Studio with MSBuild {_minimumVersion} or higher installed";
+#else
+ => $"Test runs on .NET Framework only.";
+#endif
}
}
diff --git a/src/Workspaces/MSBuildTest/VisualStudioMSBuildWorkspaceTests.cs b/src/Workspaces/MSBuildTest/VisualStudioMSBuildWorkspaceTests.cs
new file mode 100644
index 0000000000000..1225a529757c4
--- /dev/null
+++ b/src/Workspaces/MSBuildTest/VisualStudioMSBuildWorkspaceTests.cs
@@ -0,0 +1,170 @@
+// 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.
+
+#nullable disable
+
+using System;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis.Test.Utilities;
+using Microsoft.CodeAnalysis.UnitTests;
+using Microsoft.CodeAnalysis.UnitTests.TestFiles;
+using Roslyn.Test.Utilities;
+using Roslyn.Utilities;
+using Xunit;
+
+namespace Microsoft.CodeAnalysis.MSBuild.UnitTests
+{
+ public class VisualStudioMSBuildWorkspaceTests : MSBuildWorkspaceTestBase
+ {
+ // On .NET Core this tests fails with "CodePape Not Found"
+ [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ [WorkItem(991528, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/991528")]
+ public async Task MSBuildProjectShouldHandleCodePageProperty()
+ {
+ var files = new FileSet(
+ ("Encoding.csproj", Resources.ProjectFiles.CSharp.Encoding.Replace("ReplaceMe", "1254")),
+ ("class1.cs", "//\u201C"));
+
+ CreateFiles(files);
+
+ var projPath = GetSolutionFileName("Encoding.csproj");
+ using var workspace = CreateMSBuildWorkspace();
+ var project = await workspace.OpenProjectAsync(projPath);
+ var document = project.Documents.First(d => d.Name == "class1.cs");
+ var text = await document.GetTextAsync();
+ Assert.Equal(Encoding.GetEncoding(1254), text.Encoding);
+
+ // The smart quote (“) in class1.cs shows up as "“" in codepage 1254. Do a sanity
+ // check here to make sure this file hasn't been corrupted in a way that would
+ // impact subsequent asserts.
+ Assert.Equal(5, "//\u00E2\u20AC\u0153".Length);
+ Assert.Equal("//\u00E2\u20AC\u0153".Length, text.Length);
+ }
+
+ [ConditionalFact(typeof(VisualStudioMSBuildInstalled)), Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ public async Task TestAddRemoveMetadataReference_GAC()
+ {
+ CreateFiles(GetSimpleCSharpSolutionFiles());
+
+ var projFile = GetSolutionFileName(@"CSharpProject\CSharpProject.csproj");
+ var projFileText = File.ReadAllText(projFile);
+ Assert.False(projFileText.Contains(@"System.Xaml"));
+
+ using var workspace = CreateMSBuildWorkspace();
+ var solutionFilePath = GetSolutionFileName("TestSolution.sln");
+ var solution = await workspace.OpenSolutionAsync(solutionFilePath);
+ var project = solution.Projects.First();
+
+ var mref = MetadataReference.CreateFromFile(typeof(System.Xaml.XamlObjectReader).Assembly.Location);
+
+ // add reference to System.Xaml
+ workspace.TryApplyChanges(project.AddMetadataReference(mref).Solution);
+ projFileText = File.ReadAllText(projFile);
+ Assert.Contains(@"..\References\MyAssembly.dll", projFileText);
+
+ // remove reference MyAssembly.dll
+ workspace.TryApplyChanges(workspace.CurrentSolution.GetProject(project.Id).RemoveMetadataReference(mref).Solution);
+ projFileText = File.ReadAllText(projFile);
+ Assert.DoesNotContain(@"..\References\MyAssembly.dll", projFileText);
+ }
+
+ [ConditionalFact(typeof(VisualStudioMSBuildInstalled))]
+ [Trait(Traits.Feature, Traits.Features.MSBuildWorkspace)]
+ public async Task TestAddRemoveMetadataReference_ReferenceAssembly()
+ {
+ CreateFiles(GetMultiProjectSolutionFiles()
+ .WithFile(@"CSharpProject\CSharpProject.csproj", Resources.ProjectFiles.CSharp.WithSystemNumerics));
+
+ var csProjFile = GetSolutionFileName(@"CSharpProject\CSharpProject.csproj");
+ var csProjFileText = File.ReadAllText(csProjFile);
+ Assert.True(csProjFileText.Contains(@" p.Language == LanguageNames.CSharp);
+ var vbProject = solution.Projects.First(p => p.Language == LanguageNames.VisualBasic);
+
+ var numericsMetadata = csProject.MetadataReferences.Single(m => m.Display.Contains("System.Numerics"));
+
+ // add reference to System.Xaml
+ workspace.TryApplyChanges(vbProject.AddMetadataReference(numericsMetadata).Solution);
+ var newVbProjFileText = File.ReadAllText(vbProjFile);
+ Assert.Contains(@" d.Name == "App.xaml.cs");
+ Assert.Contains(documents, d => d.Name == "MainWindow.xaml.cs");
+
+ // prove no xaml files are documents
+ Assert.DoesNotContain(documents, d => d.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase));
+
+ // prove that generated source files for xaml files are included in documents list
+ Assert.Contains(documents, d => d.Name == "App.g.cs");
+ Assert.Contains(documents, d => d.Name == "MainWindow.g.cs");
+ }
+ }
+}