Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions tasks.slnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"solution": {
"path": "sdk.slnx",
"projects": [
"src\\Tasks\\Microsoft.NET.Build.Tasks\\Microsoft.NET.Build.Tasks.csproj",
"src\\Compatibility\\ApiCompat\\Microsoft.DotNet.ApiCompat.Task\\Microsoft.DotNet.ApiCompat.Task.csproj",
"src\\Tasks\\Microsoft.NET.Build.Tasks.UnitTests\\Microsoft.NET.Build.Tasks.UnitTests.csproj",
"test\\Microsoft.NET.TestFramework\\Microsoft.NET.TestFramework.csproj"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,8 @@
<Import Project="BuildTestPackages.targets" Condition="'$(BuildTestPackages)' != 'false'" />

<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<ItemGroup>
<ProjectCapability Remove="TestContainer" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ public TestProject([CallerMemberName] string? name = null)
/// </summary>
public List<string> PropertiesToRecord { get; } = new List<string>();

/// <summary>
/// The target before which to record properties specified in <see cref="PropertiesToRecord"/>.
/// Defaults to "AfterBuild".
/// </summary>
public string TargetToRecordPropertiesBefore { get; private set; } = "AfterBuild";

public IEnumerable<string> TargetFrameworkIdentifiers
{
get
Expand Down Expand Up @@ -252,7 +258,7 @@ internal void Create(TestAsset targetTestAsset, string testProjectsSourceFolder)
if(importGroup?.Attribute("Project") is not null)
{
importGroup.Attribute("Project")!.Value = "$(VSINSTALLDIR)\\MSBuild\\Microsoft\\Portable\\$(TargetFrameworkVersion)\\Microsoft.Portable.CSharp.targets";
}
}
}

if(TargetFrameworkVersion is not null)
Expand Down Expand Up @@ -375,12 +381,12 @@ internal void Create(TestAsset targetTestAsset, string testProjectsSourceFolder)

propertyGroup?.Add(new XElement(ns + "CustomAfterDirectoryBuildTargets", $"$(CustomAfterDirectoryBuildTargets);{customAfterDirectoryBuildTargetsPath.FullName}"));
propertyGroup?.Add(new XElement(ns + "CustomAfterMicrosoftCommonCrossTargetingTargets", $"$(CustomAfterMicrosoftCommonCrossTargetingTargets);{customAfterDirectoryBuildTargetsPath.FullName}"));

var customAfterDirectoryBuildTargets = new XDocument(new XElement(ns + "Project"));

var target = new XElement(ns + "Target",
new XAttribute("Name", "WritePropertyValues"),
new XAttribute("BeforeTargets", "AfterBuild"));
new XAttribute("BeforeTargets", TargetToRecordPropertiesBefore));

customAfterDirectoryBuildTargets.Root?.Add(target);

Expand Down Expand Up @@ -491,6 +497,15 @@ public void RecordProperties(params string[] propertyNames)
PropertiesToRecord.AddRange(propertyNames);
}

/// <summary>
/// Tells this TestProject to record properties specified in <see cref="PropertiesToRecord"/> before the specified target.
/// By default properties are recorded before the "AfterBuild" target (so after the actual compile+copy targets have run).
/// </summary>
public void RecordPropertiesBeforeTarget(string targetName)
{
TargetToRecordPropertiesBefore = targetName;
}

/// <returns>
/// A dictionary of property keys to property value strings, case sensitive.
/// Only properties added to the <see cref="PropertiesToRecord"/> member will be observed.
Expand Down
Loading