Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 8b07dfa

Browse files
committed
Adding the runtime identifier option to dotnet clean.
1 parent b42ac76 commit 8b07dfa

File tree

5 files changed

+96
-1
lines changed

5 files changed

+96
-1
lines changed

src/dotnet/commands/dotnet-clean/CleanCommandParser.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static Command Clean() =>
2121
.With(name: LocalizableStrings.CmdOutputDir)
2222
.ForwardAsSingle(o => $"/p:OutputPath={o.Arguments.Single()}")),
2323
CommonOptions.FrameworkOption(),
24+
CommonOptions.RuntimeOption(),
2425
CommonOptions.ConfigurationOption(),
2526
CommonOptions.VerbosityOption());
2627
}

test/Microsoft.DotNet.Cli.Tests.sln

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-back-compat.Tests",
7676
EndProject
7777
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-remove-package.Tests", "dotnet-remove-package.Tests\dotnet-remove-package.Tests.csproj", "{CF517B15-B307-4660-87D5-CC036ADECD4B}"
7878
EndProject
79-
EndProject
8079
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.MSBuildSdkResolver.Tests", "Microsoft.DotNet.MSBuildSdkResolver.Tests\Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj", "{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}"
8180
EndProject
81+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-clean.Tests", "dotnet-clean.Tests\dotnet-clean.Tests.csproj", "{D9A582B8-1FE2-45D5-B139-0BA828FE3691}"
82+
EndProject
8283
Global
8384
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8485
Debug|Any CPU = Debug|Any CPU
@@ -509,6 +510,18 @@ Global
509510
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|x64.Build.0 = Release|Any CPU
510511
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|x86.ActiveCfg = Release|Any CPU
511512
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|x86.Build.0 = Release|Any CPU
513+
{D9A582B8-1FE2-45D5-B139-0BA828FE3691}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
514+
{D9A582B8-1FE2-45D5-B139-0BA828FE3691}.Debug|Any CPU.Build.0 = Debug|Any CPU
515+
{D9A582B8-1FE2-45D5-B139-0BA828FE3691}.Debug|x64.ActiveCfg = Debug|x64
516+
{D9A582B8-1FE2-45D5-B139-0BA828FE3691}.Debug|x64.Build.0 = Debug|x64
517+
{D9A582B8-1FE2-45D5-B139-0BA828FE3691}.Debug|x86.ActiveCfg = Debug|x86
518+
{D9A582B8-1FE2-45D5-B139-0BA828FE3691}.Debug|x86.Build.0 = Debug|x86
519+
{D9A582B8-1FE2-45D5-B139-0BA828FE3691}.Release|Any CPU.ActiveCfg = Release|Any CPU
520+
{D9A582B8-1FE2-45D5-B139-0BA828FE3691}.Release|Any CPU.Build.0 = Release|Any CPU
521+
{D9A582B8-1FE2-45D5-B139-0BA828FE3691}.Release|x64.ActiveCfg = Release|x64
522+
{D9A582B8-1FE2-45D5-B139-0BA828FE3691}.Release|x64.Build.0 = Release|x64
523+
{D9A582B8-1FE2-45D5-B139-0BA828FE3691}.Release|x86.ActiveCfg = Release|x86
524+
{D9A582B8-1FE2-45D5-B139-0BA828FE3691}.Release|x86.Build.0 = Release|x86
512525
EndGlobalSection
513526
GlobalSection(SolutionProperties) = preSolution
514527
HideSolutionNode = FALSE

test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoAssertions.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,22 @@ public AndConstraint<DirectoryInfoAssertions> OnlyHaveFiles(IEnumerable<string>
191191
return new AndConstraint<DirectoryInfoAssertions>(this);
192192
}
193193

194+
public AndConstraint<DirectoryInfoAssertions> BeEmpty()
195+
{
196+
Execute.Assertion.ForCondition(!_dirInfo.EnumerateFileSystemInfos().Any())
197+
.FailWith($"The directory {_dirInfo.FullName} is not empty.");
198+
199+
return new AndConstraint<DirectoryInfoAssertions>(this);
200+
}
201+
202+
public AndConstraint<DirectoryInfoAssertions> NotBeEmpty()
203+
{
204+
Execute.Assertion.ForCondition(_dirInfo.EnumerateFileSystemInfos().Any())
205+
.FailWith($"The directory {_dirInfo.FullName} is empty.");
206+
207+
return new AndConstraint<DirectoryInfoAssertions>(this);
208+
}
209+
194210
public AndConstraint<DirectoryInfoAssertions> NotExist(string because = "", params object[] reasonArgs)
195211
{
196212
Execute.Assertion
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.IO;
6+
using FluentAssertions;
7+
using Microsoft.DotNet.Tools.Test.Utilities;
8+
using Xunit;
9+
using System.Linq;
10+
11+
namespace Microsoft.DotNet.Cli.Clean.Tests
12+
{
13+
public class GivenDotnetCleanCleansBuildArtifacts : TestBase
14+
{
15+
[Fact]
16+
public void ItCleansAProjectBuiltWithRuntimeIdentifier()
17+
{
18+
var testAppName = "MSBuildTestApp";
19+
var testInstance = TestAssets.Get(testAppName)
20+
.CreateInstance(testAppName)
21+
.WithSourceFiles()
22+
.WithRestoreFiles();
23+
24+
new BuildCommand()
25+
.WithRuntime("win7-x64")
26+
.WithWorkingDirectory(testInstance.Root)
27+
.Execute()
28+
.Should().Pass();
29+
30+
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
31+
var outputFolder = testInstance.Root.GetDirectory("bin", configuration, "netcoreapp2.0", "win7-x64");
32+
33+
outputFolder.Should().NotBeEmpty();
34+
35+
new CleanCommand()
36+
.WithWorkingDirectory(testInstance.Root)
37+
.Execute("-r win7-x64")
38+
.Should().Pass();
39+
40+
outputFolder.Should().BeEmpty();
41+
}
42+
}
43+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
3+
4+
<PropertyGroup>
5+
<TargetFramework>$(CliTargetFramework)</TargetFramework>
6+
<RuntimeFrameworkVersion>$(CLI_SharedFrameworkVersion)</RuntimeFrameworkVersion>
7+
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
8+
<AssemblyName>dotnet-clean.Tests</AssemblyName>
9+
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\Microsoft.DotNet.Tools.Tests.Utilities\Microsoft.DotNet.Tools.Tests.Utilities.csproj" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20161024-02" />
18+
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta4-build1194" />
19+
<PackageReference Include="xunit" Version="2.2.0-beta4-build3444" />
20+
</ItemGroup>
21+
22+
</Project>

0 commit comments

Comments
 (0)