Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove MSBuild and Mono from release packages #2360

Merged
merged 26 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cd4de6d
Remove MSBuild and Mono from release packages
JoeRobich Feb 19, 2022
bfa5b55
Fix publishing errors.
JoeRobich Mar 17, 2022
4689758
Update vm images used in CI
JoeRobich Mar 18, 2022
6e017f8
Remove reference to `omnisharp.useGlobalMono` from messages
JoeRobich Mar 18, 2022
1be42f3
Remove `UseBundledOnly` MSBuild Option.
JoeRobich Mar 18, 2022
b1fe1e6
Adjust project capabilities test
JoeRobich Mar 18, 2022
556b29f
Include SQLitePCLRaw in .NET Framework test output
JoeRobich Mar 18, 2022
bd23d5a
Fix test
JoeRobich Mar 18, 2022
c0cdf55
Simplify getting MSBuildLocator in tests
JoeRobich Mar 20, 2022
784f2a7
Merge branch 'master' into remove-tooling
JoeRobich Mar 20, 2022
d34a431
Restore Mono test behavior
JoeRobich Mar 20, 2022
6071873
Merge branch 'remove-tooling' of github.com:JoeRobich/omnisharp-rosly…
JoeRobich Mar 20, 2022
ca1a590
Copy only the necessary MSBuild libraries
JoeRobich Mar 20, 2022
b0eb7d6
Copy Mono MSBuild files when testing but do not overwrite
JoeRobich Mar 20, 2022
78bdcc4
Copy SQLite libraries during Mono tests
JoeRobich Mar 20, 2022
3ccc284
Run OmniSharpMSBuild.Tests on Mono in CI
JoeRobich Mar 20, 2022
9855687
Remove unused code
JoeRobich Mar 20, 2022
1bb8c93
Skip NET5+ MSBuild tests against Mono
JoeRobich Mar 20, 2022
097a354
Restore run script in Mono O# packages
JoeRobich Mar 21, 2022
c24a1e0
Add warning when using deprecated 'UseBundledOnly' option
JoeRobich Mar 24, 2022
f176822
Create logger before using it.
JoeRobich Mar 24, 2022
c38a67f
Use nullable type for option value.
JoeRobich Mar 24, 2022
c662bba
Parse option as a string
JoeRobich Mar 24, 2022
8201fef
Pass default value when getting option
JoeRobich Mar 24, 2022
18bc3ba
Handle null configuration
JoeRobich Mar 24, 2022
24c0c0f
Update changelog
JoeRobich Mar 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify getting MSBuildLocator in tests
  • Loading branch information
JoeRobich committed Mar 20, 2022
commit c0cdf55ce2e10ae163378d70f56eeeb6ac41bafd
25 changes: 3 additions & 22 deletions src/OmniSharp.Host/MSBuild/Discovery/MSBuildLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Immutable;
using System.IO;
using System.Reflection;
//using System.Runtime.Loader;
using System.Text;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
Expand All @@ -15,16 +14,6 @@ namespace OmniSharp.MSBuild.Discovery
{
internal class MSBuildLocator : DisposableObject, IMSBuildLocator
{
private const string MSBuildPublicKeyToken = "b03f5f7f11d50a3a";

private static readonly string[] s_msBuildAssemblies =
{
"Microsoft.Build",
"Microsoft.Build.Framework",
"Microsoft.Build.Tasks.Core",
"Microsoft.Build.Utilities.Core",
};

private readonly ILogger _logger;
private readonly ImmutableArray<MSBuildInstanceProvider> _providers;

Expand Down Expand Up @@ -100,20 +89,12 @@ public void RegisterInstance(MSBuildInstance instance)

_logger.LogInformation(builder.ToString());

if (MicrosoftBuildLocator.CanRegister)
if (!MicrosoftBuildLocator.CanRegister)
{
MicrosoftBuildLocator.RegisterMSBuildPath(instance.MSBuildPath);
return;
}

foreach (var msBuildAssemblyName in s_msBuildAssemblies)
{
var assembly = Assembly.Load($"{msBuildAssemblyName}, Version=15.1.0.0, Culture=neutral, PublicKeyToken={MSBuildPublicKeyToken}");
if (assembly is null)
{
throw new Exception($"Unable to load {msBuildAssemblyName}'");
}
_logger.LogInformation($"Loaded {msBuildAssemblyName} from '{assembly.Location}'");
}
MicrosoftBuildLocator.RegisterMSBuildPath(instance.MSBuildPath);
}

public ImmutableArray<MSBuildInstance> GetInstances()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<PackageReference Include="xunit" />
<!--
Mono's MSBuild does not include the SQLitePCLRaw libraries.
We include them when packaging our non-windows .NET Framework builds.
Simulate that behavior for these tests.
We include them when packaging our non-windows .NET Framework builds.
Simulate that behavior for these tests.
-->
<PackageReference Include="SQLitePCLRaw.bundle_green" Condition="'$(TargetFramework)' == 'net472'" />
<PackageReference Include="SQLitePCLRaw.bundle_green" PrivateAssets="all" Condition="'$(TargetFramework)' != 'net472'" />
Expand Down
4 changes: 2 additions & 2 deletions tests/OmniSharp.Lsp.Tests/OmniSharp.Lsp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<PackageReference Include="xunit" />
<!--
Mono's MSBuild does not include the SQLitePCLRaw libraries.
We include them when packaging our non-windows .NET Framework builds.
Simulate that behavior for these tests.
We include them when packaging our non-windows .NET Framework builds.
Simulate that behavior for these tests.
-->
<PackageReference Include="SQLitePCLRaw.bundle_green" Condition="'$(TargetFramework)' == 'net472'" />
<PackageReference Include="SQLitePCLRaw.bundle_green" PrivateAssets="all" Condition="'$(TargetFramework)' != 'net472'" />
Expand Down
11 changes: 4 additions & 7 deletions tests/OmniSharp.MSBuild.Tests/AbstractMSBuildTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@ public abstract class AbstractMSBuildTestFixture : AbstractTestFixture, IDisposa
private readonly IMSBuildLocator _msbuildLocator;
private readonly IAnalyzerAssemblyLoader _analyzerAssemblyLoader;

public AbstractMSBuildTestFixture(ITestOutputHelper output, SharedOmniSharpHostFixture sharedOmniSharpHostFixture)
: base(output, sharedOmniSharpHostFixture)
public AbstractMSBuildTestFixture(ITestOutputHelper output)
: base(output)
{
_assemblyLoader = new AssemblyLoader(this.LoggerFactory);
_analyzerAssemblyLoader = ShadowCopyAnalyzerAssemblyLoader.Instance;
_msbuildLocator = this.SharedOmniSharpTestHost.ServiceProvider.GetRequiredService<IMSBuildLocator>();
_msbuildLocator = MSBuildLocator.CreateDefault(this.LoggerFactory, _assemblyLoader, msbuildConfiguration: null);

//if (_msbuildLocator.RegisteredInstance is null)
//{
// Some tests require MSBuild to be discovered early
// to ensure that the Microsoft.Build.* assemblies can be located
// _msbuildLocator.RegisterDefaultInstance(this.LoggerFactory.CreateLogger("MSBuildTests"), dotNetInfo: null);
//}
_msbuildLocator.RegisterDefaultInstance(this.LoggerFactory.CreateLogger("MSBuildTests"), dotNetInfo: null);
}

public void Dispose()
Expand Down
5 changes: 2 additions & 3 deletions tests/OmniSharp.MSBuild.Tests/LoadProjectsOnDemandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using OmniSharp.Models;
using OmniSharp.Models.MembersTree;
using OmniSharp.Models.V2.CodeActions;
using OmniSharp.Models.V2.CodeStructure;
using OmniSharp.MSBuild.Models;
using OmniSharp.Options;
using OmniSharp.Roslyn.CSharp.Services.Refactoring.V2;
Expand All @@ -17,8 +16,8 @@ namespace OmniSharp.MSBuild.Tests
{
public class LoadProjectsOnDemandTests : AbstractMSBuildTestFixture
{
public LoadProjectsOnDemandTests(ITestOutputHelper output, SharedOmniSharpHostFixture sharedOmniSharpHostFixture)
: base(output, sharedOmniSharpHostFixture)
public LoadProjectsOnDemandTests(ITestOutputHelper output)
: base(output)
{
}

Expand Down
4 changes: 1 addition & 3 deletions tests/OmniSharp.MSBuild.Tests/MSBuildDiagnosticTests.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
using Microsoft.Build.Framework;
using OmniSharp.MSBuild.Logging;
using OmniSharp.Utilities;
using TestUtility;
using Xunit;
using Xunit.Abstractions;

namespace OmniSharp.MSBuild.Tests
{
public class MSBuildDiagnosticTests : AbstractMSBuildTestFixture
{
public MSBuildDiagnosticTests(ITestOutputHelper output, SharedOmniSharpHostFixture sharedOmniSharpHostFixture)
: base(output, sharedOmniSharpHostFixture)
public MSBuildDiagnosticTests(ITestOutputHelper output) : base(output)
{
}

Expand Down
4 changes: 2 additions & 2 deletions tests/OmniSharp.MSBuild.Tests/NotificationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace OmniSharp.MSBuild.Tests
{
public class NotificationTests : AbstractMSBuildTestFixture
{
public NotificationTests(ITestOutputHelper output, SharedOmniSharpHostFixture sharedOmniSharpHostFixture)
: base(output, sharedOmniSharpHostFixture)
public NotificationTests(ITestOutputHelper output)
: base(output)
{
}

Expand Down
4 changes: 2 additions & 2 deletions tests/OmniSharp.MSBuild.Tests/OmniSharp.MSBuild.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<PackageReference Include="Microsoft.Build" ExcludeAssets="Runtime" PrivateAssets="all" />
<!--
Mono's MSBuild does not include the SQLitePCLRaw libraries.
We include them when packaging our non-windows .NET Framework builds.
Simulate that behavior for these tests.
We include them when packaging our non-windows .NET Framework builds.
Simulate that behavior for these tests.
-->
<PackageReference Include="SQLitePCLRaw.bundle_green" Condition="'$(TargetFramework)' == 'net472'" />
<PackageReference Include="SQLitePCLRaw.bundle_green" PrivateAssets="all" Condition="'$(TargetFramework)' != 'net472'" />
Expand Down
3 changes: 1 addition & 2 deletions tests/OmniSharp.MSBuild.Tests/ProjectLoadListenerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public partial class ProjectLoadListenerTests : AbstractMSBuildTestFixture
private readonly VsTfmAndFileExtHashingAlgorithm _tfmAndFileHashingAlgorithm;
private readonly VsReferenceHashingAlgorithm _referenceHashingAlgorithm;

public ProjectLoadListenerTests(ITestOutputHelper output, SharedOmniSharpHostFixture sharedOmniSharpHostFixture)
: base(output, sharedOmniSharpHostFixture)
public ProjectLoadListenerTests(ITestOutputHelper output) : base(output)
{
_tfmAndFileHashingAlgorithm = new VsTfmAndFileExtHashingAlgorithm();
_referenceHashingAlgorithm = new VsReferenceHashingAlgorithm();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace OmniSharp.MSBuild.Tests
{
public class ProjectWithAdditionalFilesTests : AbstractMSBuildTestFixture
{
public ProjectWithAdditionalFilesTests(ITestOutputHelper output, SharedOmniSharpHostFixture sharedOmniSharpHostFixture)
: base(output, sharedOmniSharpHostFixture)
public ProjectWithAdditionalFilesTests(ITestOutputHelper output)
: base(output)
{
}

Expand Down
4 changes: 2 additions & 2 deletions tests/OmniSharp.MSBuild.Tests/ProjectWithAnalyzersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ namespace OmniSharp.MSBuild.Tests
{
public class ProjectWithAnalyzersTests : AbstractMSBuildTestFixture
{
public ProjectWithAnalyzersTests(ITestOutputHelper output, SharedOmniSharpHostFixture sharedOmniSharpHostFixture)
: base(output, sharedOmniSharpHostFixture)
public ProjectWithAnalyzersTests(ITestOutputHelper output)
: base(output)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace OmniSharp.MSBuild.Tests
{
public class ProjectWithComplexAnalyzersTests : AbstractMSBuildTestFixture
{
public ProjectWithComplexAnalyzersTests(ITestOutputHelper output, SharedOmniSharpHostFixture sharedOmniSharpHostFixture)
: base(output, sharedOmniSharpHostFixture)
public ProjectWithComplexAnalyzersTests(ITestOutputHelper output) : base(output)
{
}

Expand Down
4 changes: 2 additions & 2 deletions tests/OmniSharp.MSBuild.Tests/WorkspaceInformationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ namespace OmniSharp.MSBuild.Tests
{
public class WorkspaceInformationTests : AbstractMSBuildTestFixture
{
public WorkspaceInformationTests(ITestOutputHelper output, SharedOmniSharpHostFixture sharedOmniSharpHostFixture)
: base(output, sharedOmniSharpHostFixture)
public WorkspaceInformationTests(ITestOutputHelper output)
: base(output)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<PackageReference Include="xunit" />
<!--
Mono's MSBuild does not include the SQLitePCLRaw libraries.
We include them when packaging our non-windows .NET Framework builds.
Simulate that behavior for these tests.
We include them when packaging our non-windows .NET Framework builds.
Simulate that behavior for these tests.
-->
<PackageReference Include="SQLitePCLRaw.bundle_green" Condition="'$(TargetFramework)' == 'net472'" />
<PackageReference Include="SQLitePCLRaw.bundle_green" PrivateAssets="all" Condition="'$(TargetFramework)' != 'net472'" />
Expand Down
4 changes: 2 additions & 2 deletions tests/OmniSharp.Stdio.Tests/OmniSharp.Stdio.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<PackageReference Include="xunit" />
<!--
Mono's MSBuild does not include the SQLitePCLRaw libraries.
We include them when packaging our non-windows .NET Framework builds.
Simulate that behavior for these tests.
We include them when packaging our non-windows .NET Framework builds.
Simulate that behavior for these tests.
-->
<PackageReference Include="SQLitePCLRaw.bundle_green" Condition="'$(TargetFramework)' == 'net472'" />
<PackageReference Include="SQLitePCLRaw.bundle_green" PrivateAssets="all" Condition="'$(TargetFramework)' != 'net472'" />
Expand Down
2 changes: 1 addition & 1 deletion tests/TestUtility/TestServiceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private static IConfigurationRoot CreateConfiguration(IConfiguration configurati

private static IMSBuildLocator CreateMSBuildLocator(ILoggerFactory loggerFactory,
IAssemblyLoader assemblyLoader,
IConfiguration configurationData)
IConfiguration configurationData = null)
=> MSBuildLocator.CreateDefault(loggerFactory, assemblyLoader, configurationData);

private static ISharedTextWriter CreateSharedTextWriter(ITestOutputHelper testOutput)
Expand Down