diff --git a/test/EndToEnd/GivenDotnetUsesDotnetTools.cs b/test/EndToEnd/GivenDotnetUsesDotnetTools.cs index c9b46d6a9..3e32c4a45 100644 --- a/test/EndToEnd/GivenDotnetUsesDotnetTools.cs +++ b/test/EndToEnd/GivenDotnetUsesDotnetTools.cs @@ -6,7 +6,7 @@ namespace EndToEnd { public class GivenDotnetUsesDotnetTools : TestBase { - [Fact] + [RequiresAspNetCore] public void ThenOneDotnetToolsCanBeCalled() { new DotnetCommand() diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs index de2af4896..96fba749a 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs @@ -19,6 +19,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities private string _builtDotnet; private string _nugetPackages; private string _stage2Sdk; + private string _stage2AspNetCore; private string _stage2WithBackwardsCompatibleRuntimesDirectory; private string _testPackages; private string _testWorkingFolder; @@ -90,6 +91,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public string DotnetRoot => _dotnetRoot; public string NugetPackages => _nugetPackages; public string Stage2Sdk => _stage2Sdk; + public string Stage2AspNetCore => _stage2AspNetCore; public string Stage2WithBackwardsCompatibleRuntimesDirectory => _stage2WithBackwardsCompatibleRuntimesDirectory; public string TestPackages => _testPackages; public string TestWorkingFolder => _testWorkingFolder; @@ -116,6 +118,12 @@ namespace Microsoft.DotNet.Tools.Test.Utilities .EnumerateDirectories(Path.Combine(_artifacts, "dotnet", "sdk")) .First(d => !d.Contains("NuGetFallbackFolder")); + string AspNetCoreDir = Path.Combine(_dotnetRoot, "shared", "Microsoft.AspNetCore.App"); + if (Directory.Exists(AspNetCoreDir)) + { + _stage2AspNetCore = Directory.EnumerateDirectories(AspNetCoreDir).First(); + } + _stage2WithBackwardsCompatibleRuntimesDirectory = Path.Combine(_artifacts, "dotnetWithBackwardsCompatibleRuntimes"); diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/RequiresAspNetCore.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/RequiresAspNetCore.cs new file mode 100644 index 000000000..e55474843 --- /dev/null +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/RequiresAspNetCore.cs @@ -0,0 +1,20 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Xunit; + +namespace Microsoft.DotNet.Tools.Test.Utilities +{ + public class RequiresAspNetCore : FactAttribute + { + public RequiresAspNetCore() + { + var repoDirectoriesProvider = new RepoDirectoriesProvider(); + + if (repoDirectoriesProvider.Stage2AspNetCore == null) + { + this.Skip = $"This test requires a AspNetCore but it isn't present."; + } + } + } +}