parent
9862fbb4d7
commit
3a3ab7e0b0
7 changed files with 70 additions and 17 deletions
|
@ -2,6 +2,8 @@
|
|||
<Project ToolsVersion="14.0" DefaultTargets="Validate"
|
||||
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<Import Project="build.props" />
|
||||
|
||||
<Target Name="Build"
|
||||
DependsOnTargets="Validate" />
|
||||
|
||||
|
@ -22,13 +24,22 @@
|
|||
|
||||
<Target Name="Validate">
|
||||
<Error Condition=" $(MSBuildNodeCount) < 2 "
|
||||
Text="Expect MSBuildNodeCount to be greater than 1, but found $(MSBuildNodeCount). Is this a single proc machine?" />
|
||||
Text="Expected MSBuildNodeCount to be greater than 1, but found $(MSBuildNodeCount). Is this a single proc machine?" />
|
||||
|
||||
<Error Condition=" '$(MSBuildExtensionsPath)' == '' "
|
||||
Text="Expect MSBuildExtensionsPath to be set, but it is not." />
|
||||
Text="Expected MSBuildExtensionsPath to be set, but it is not." />
|
||||
|
||||
<Error Condition=" '$(CscToolExe)' == '' "
|
||||
Text="Expect CscToolExe to be set, but it is not." />
|
||||
Text="Expected CscToolExe to be set, but it is not." />
|
||||
|
||||
<Error Condition=" '$(MSBuildSDKsPath)' == '' "
|
||||
Text="Expected MSBuildSDKsPath to be set, but it is not." />
|
||||
|
||||
<Error Condition=" !Exists('$(MSBuildSDKsPath)/%(Sdk.Identity)/%(Sdk.Version)/build/InitialImport.props') "
|
||||
Text="Expected '$(MSBuildSDKsPath)/%(Sdk.Identity)/%(Sdk.Version)/build/InitialImport.props' to exist, but it does not. " />
|
||||
|
||||
<Error Condition=" !Exists('$(MSBuildSDKsPath)/%(Sdk.Identity)/%(Sdk.Version)/build/FinalImport.targets') "
|
||||
Text="Expected '$(MSBuildSDKsPath)/%(Sdk.Identity)/%(Sdk.Version)/build/FinalImport.targets' to exist, but it does not. " />
|
||||
|
||||
<Message Importance="low" Text="Message with low importance" />
|
||||
<Message Importance="normal" Text="Message with normal importance" />
|
||||
|
|
6
TestAssets/TestProjects/MSBuildIntegration/build.props
Normal file
6
TestAssets/TestProjects/MSBuildIntegration/build.props
Normal file
|
@ -0,0 +1,6 @@
|
|||
<Project ToolsVersion="14.0" DefaultTargets="Validate">
|
||||
<ItemGroup>
|
||||
<Sdk Include="Microsoft.Core.Sdk" Version="1.0.0-RC2" />
|
||||
<Sdk Include="Microsoft.Web.Sdk" Version="1.0.0-RC2" />
|
||||
</ItemGroup>
|
||||
</Project>
|
6
build/Microsoft.DotNet.Cli.BundledSdks.props
Normal file
6
build/Microsoft.DotNet.Cli.BundledSdks.props
Normal file
|
@ -0,0 +1,6 @@
|
|||
<Project ToolsVersion="15.0">
|
||||
<ItemGroup>
|
||||
<BundledSdk Include="Microsoft.Core.Sdk" Version="1.0.0-RC2" />
|
||||
<BundledSdk Include="Microsoft.Web.Sdk" Version="1.0.0-RC2" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -18,8 +18,9 @@
|
|||
<Target Name="Compile" DependsOnTargets="Prepare;
|
||||
SetupStage;
|
||||
CompileStage;
|
||||
PublishSdks;
|
||||
BuildProjectsForNuGetPackages;
|
||||
GetNuGetPackagesArchive" />
|
||||
GetNuGetPackagesArchive;" />
|
||||
|
||||
<Target Name="SetupStage"
|
||||
DependsOnTargets="Prepare">
|
||||
|
@ -242,4 +243,18 @@
|
|||
|
||||
<Delete Files="@(PdbsToClean)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="PublishSdks">
|
||||
<MakeDir Directories="$(SdkOutputDirectory)/Extensions/%(BundledSdk.Identity)/%(BundledSdk.Version)/build/" />
|
||||
|
||||
<!-- Generate sdk placeholder files -->
|
||||
<WriteLinesToFile File="$(SdkOutputDirectory)/Extensions/%(BundledSdk.Identity)/%(BundledSdk.Version)/build/InitialImport.props"
|
||||
Lines="placeholder"
|
||||
Overwrite="true" />
|
||||
|
||||
<WriteLinesToFile File="$(SdkOutputDirectory)/Extensions/%(BundledSdk.Identity)/%(BundledSdk.Version)/build/FinalImport.targets"
|
||||
Lines="placeholder"
|
||||
Overwrite="true" />
|
||||
|
||||
</Target>
|
||||
</Project>
|
|
@ -2,6 +2,7 @@
|
|||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="Microsoft.DotNet.Cli.tasks" />
|
||||
<Import Project="prepare/CheckPrereqs.targets" />
|
||||
<Import Project="Microsoft.DotNet.Cli.BundledSdks.props" />
|
||||
|
||||
<Target Name="Prepare"
|
||||
DependsOnTargets="Init;DownloadHostAndSharedFxArtifacts;RestoreSrcPackages;RestoreToolsPackages;ZipTemplates" />
|
||||
|
|
|
@ -16,7 +16,9 @@ namespace Microsoft.DotNet.Tools.MSBuild
|
|||
{
|
||||
internal const string TelemetrySessionIdEnvironmentVariableName = "DOTNET_CLI_TELEMETRY_SESSIONID";
|
||||
|
||||
private const string s_msbuildExeName = "MSBuild.dll";
|
||||
private const string MSBuildExeName = "MSBuild.dll";
|
||||
|
||||
private const string ExtensionsDirectoryName = "Extensions";
|
||||
|
||||
private readonly ForwardingApp _forwardingApp;
|
||||
|
||||
|
@ -24,7 +26,8 @@ namespace Microsoft.DotNet.Tools.MSBuild
|
|||
new Dictionary<string, string>
|
||||
{
|
||||
{ "MSBuildExtensionsPath", AppContext.BaseDirectory },
|
||||
{ "CscToolExe", GetRunCscPath() }
|
||||
{ "CscToolExe", GetRunCscPath() },
|
||||
{ "MSBuildSDKsPath", GetMSBuildSDKsPath() }
|
||||
};
|
||||
|
||||
private readonly IEnumerable<string> _msbuildRequiredParameters =
|
||||
|
@ -78,7 +81,14 @@ namespace Microsoft.DotNet.Tools.MSBuild
|
|||
{
|
||||
return Path.Combine(
|
||||
AppContext.BaseDirectory,
|
||||
s_msbuildExeName);
|
||||
MSBuildExeName);
|
||||
}
|
||||
|
||||
private static string GetMSBuildSDKsPath()
|
||||
{
|
||||
return Path.Combine(
|
||||
AppContext.BaseDirectory,
|
||||
ExtensionsDirectoryName);
|
||||
}
|
||||
|
||||
private static string GetRunCscPath()
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace Microsoft.DotNet.Cli.MSBuild.IntegrationTests
|
|||
[Theory]
|
||||
[InlineData("build")]
|
||||
[InlineData("clean")]
|
||||
[InlineData("msbuild")]
|
||||
[InlineData("pack")]
|
||||
[InlineData("publish")]
|
||||
public void When_dotnet_command_invokes_msbuild_with_no_args_verbosity_is_set_to_minimum(string command)
|
||||
|
@ -46,10 +47,12 @@ namespace Microsoft.DotNet.Cli.MSBuild.IntegrationTests
|
|||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(testInstance.Root)
|
||||
.ExecuteWithCapturedOutput(command);
|
||||
|
||||
cmd.Should().Pass();
|
||||
cmd.StdOut.Should().NotContain("Message with normal importance");
|
||||
// sanity check
|
||||
cmd.StdOut.Should().Contain("Message with high importance");
|
||||
|
||||
cmd.StdOut
|
||||
.Should().NotContain("Message with normal importance", "Because verbosity is set to minimum")
|
||||
.And.Contain("Message with high importance", "Because high importance messages are shown on minimum verbosity");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
@ -57,7 +60,6 @@ namespace Microsoft.DotNet.Cli.MSBuild.IntegrationTests
|
|||
[InlineData("clean")]
|
||||
[InlineData("pack")]
|
||||
[InlineData("publish")]
|
||||
[InlineData("test")]
|
||||
public void When_dotnet_command_invokes_msbuild_with_diag_verbosity_Then_arg_is_passed(string command)
|
||||
{
|
||||
var testInstance = TestAssets.Get("MSBuildIntegration")
|
||||
|
@ -67,21 +69,23 @@ namespace Microsoft.DotNet.Cli.MSBuild.IntegrationTests
|
|||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(testInstance.Root)
|
||||
.ExecuteWithCapturedOutput($"{command} -v diag");
|
||||
|
||||
cmd.Should().Pass();
|
||||
|
||||
cmd.StdOut.Should().Contain("Message with low importance");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void When_dotnet_test_invokes_msbuild_with_no_args_verbosity_is_set_to_quiet()
|
||||
{
|
||||
string command = "test";
|
||||
var testInstance = TestAssets.Get("MSBuildIntegration")
|
||||
.CreateInstance(identifier: command)
|
||||
.CreateInstance()
|
||||
.WithSourceFiles();
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(testInstance.Root)
|
||||
.ExecuteWithCapturedOutput(command);
|
||||
.ExecuteWithCapturedOutput("test");
|
||||
|
||||
cmd.Should().Pass();
|
||||
cmd.StdOut.Should().NotContain("Message with high importance");
|
||||
}
|
||||
|
@ -89,14 +93,14 @@ namespace Microsoft.DotNet.Cli.MSBuild.IntegrationTests
|
|||
[Fact]
|
||||
public void When_dotnet_msbuild_command_is_invoked_with_non_msbuild_switch_Then_it_fails()
|
||||
{
|
||||
string command = "msbuild";
|
||||
var testInstance = TestAssets.Get("MSBuildIntegration")
|
||||
.CreateInstance(identifier: command)
|
||||
.CreateInstance()
|
||||
.WithSourceFiles();
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(testInstance.Root)
|
||||
.ExecuteWithCapturedOutput($"{command} -v diag");
|
||||
.ExecuteWithCapturedOutput($"msbuild -v diag");
|
||||
|
||||
cmd.ExitCode.Should().NotBe(0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue