Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bdd78a6
Adds an item group, outputProperties, which defaults to TargetFramewo…
Jun 11, 2020
cdfd098
Update src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.…
laurenprinn Jun 15, 2020
028f74a
Changing the LogOutputProperties item to be similar to a key-value pa…
Jun 24, 2020
87a401f
Changed item name to be more descriptive to its purpose
Jun 26, 2020
b07748b
Renaming item
Jul 6, 2020
28ffa1e
Update src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.…
laurenprinn Jul 23, 2020
175acfb
Update src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.…
laurenprinn Jul 23, 2020
31ef8f6
:qd
Jul 30, 2020
ce58d6b
Test to check if by default TargetFramework is printed in logger if T…
Aug 14, 2020
16bedf9
Merge remote-tracking branch 'upstream/master' into outputProperties_…
Aug 14, 2020
0d04c66
Update ProjectConfigurationDescriptionTest.cs
laurenprinn Jun 10, 2021
a044fd0
Merge remote-tracking branch 'upstream/release/6.0.2xx' into outputPr…
rainersigwald Jan 14, 2022
db3d929
Merge remote-tracking branch 'upstream/release/6.0.3xx' into outputPr…
rainersigwald Feb 9, 2022
7a6ca86
Merge remote-tracking branch 'upstream/main' into outputProperties_it…
rainersigwald May 9, 2022
91cb9b0
Adapt unit test to new format
rainersigwald May 10, 2022
86a4f0b
Delete extra copy of test file
rainersigwald May 10, 2022
f5c83c1
Undo whitespace changes
rainersigwald Jun 7, 2022
b00ae4e
Copyright header for new test file
rainersigwald Jun 8, 2022
e5987b8
Test needs MSBuild 17.2+
rainersigwald Jun 22, 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
45 changes: 45 additions & 0 deletions ProjectConfigurationDescriptionTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
namespace Microsoft.NET.Build.Tests
{
public class ProjecyConfigurationDescription : SdkTest
{
public void ProjectConfigurationDescription_DefaultTest()
{
var testProj = new TestProject()
{
Name = "CompilationConstants",
TargetFrameworks = "netcoreapp2.1;netcoreapp3.1",
IsExe = true,
IsSdkProject = true
};

var testAsset = _testAssetsManager.CreateTestProject(testProj);
File.WriteAllText(Path.Combine(testAsset.Path, testProj.Name, $"{testProj.Name}.cs"), @"
using System;
class Program
{
static void Main(string[] args)
{
#if NETCOREAPP2_1
Consol.WriteLine(""NETCOREAPP2_1"");
#endif
#if NETCOREAPP3_1
Console.WriteLine(""NETCOREAPP3_1"");
#endif
}
}");

var buildCommand = new BuildCommand(Log, Path.Combine(testAsset.Path, testProj.Name));
buildCommand
.Execute()
.Should()
.Pass();

var runCommand = new RunExeCommand(Log, Path.Combine(buildCommand.GetOutputDirectory(targetFramework).FullName, $"{testProj.Name}.exe"));
var stdOut = runCommand.Execute().StdOut.Split(Environment.NewLine.ToCharArray()).Where(line => !string.IsNullOrWhiteSpace(line));
stdOut.Should().BeEquivalentTo(expectedOutput);

//line 745 can be used to do the should fail expected output thing
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ Copyright (c) .NET Foundation. All rights reserved.
<GenerateRuntimeConfigurationFilesInputs Include="$(UserRuntimeConfig)" Condition=" Exists($(UserRuntimeConfig)) " />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworks)' != '' And '$(TargetFramework)' != ''">
<ProjectConfigurationDescription Include="TargetFramework=$(TargetFramework)"/>
</ItemGroup>

<PropertyGroup>
<ProjectDepsFileName Condition="'$(ProjectDepsFileName)' == ''">$(AssemblyName).deps.json</ProjectDepsFileName>
<ProjectDepsFilePath Condition="'$(ProjectDepsFilePath)' == ''">$(TargetDir)$(ProjectDepsFileName)</ProjectDepsFilePath>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.IO;
using Microsoft.NET.TestFramework;
using Microsoft.NET.TestFramework.Assertions;
using Microsoft.NET.TestFramework.Commands;
using FluentAssertions;
using Microsoft.NET.TestFramework.ProjectConstruction;
using Xunit.Abstractions;
using Xunit;

namespace Microsoft.NET.Build.Tests
{
public class ProjectConfigurationDescription : SdkTest
{
public ProjectConfigurationDescription(ITestOutputHelper log) : base(log)
{
}

[Fact]
public void ProjectConfigurationDescription_DefaultTest()
{
var testProj = new TestProject()
{
Name = "CompilationConstants",
TargetFrameworks = "netcoreapp2.1;netcoreapp3.1",
IsExe = true,
IsSdkProject = true
};

var testAsset = _testAssetsManager.CreateTestProject(testProj);
File.WriteAllText(Path.Combine(testAsset.Path, testProj.Name, $"{testProj.Name}.cs"), @"
using System;
class Program
{
static void Main(string[] args)
{
#if NETCOREAPP2_1
Consol.WriteLine(""NETCOREAPP2_1"");
#endif
#if NETCOREAPP3_1
Console.WriteLine(""NETCOREAPP3_1"");
#endif
}
}");

var buildCommand = new BuildCommand(Log, Path.Combine(testAsset.Path, testProj.Name));
buildCommand
.Execute()
.Should()
.Fail()
.And
.HaveStdOutContaining(":: TargetFramework");
}
}
}