Skip to content

Commit

Permalink
Remove psc error added in 7.0.2xx merge, and remove changes to testpr…
Browse files Browse the repository at this point in the history
…oject so changes from publishrid can be used instead
  • Loading branch information
nagilson committed Nov 2, 2022
1 parent 509598d commit a6e5ce0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ Copyright (c) .NET Foundation. All rights reserved.
ResourceName="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed"
FormatArguments="SelfContained"/>

<NETSdkError Condition="'$(_PublishSelfContainedIsActive)' == 'true' and '$(PublishSelfContained)' == 'true' and '$(RuntimeIdentifier)' == '' and '$(RuntimeIdentifiers)' == ''"
ResourceName="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed"
FormatArguments="PublishSelfContained"/>

<NETSdkError Condition="'$(PublishReadyToRun)' == 'true' and '$(RuntimeIdentifier)' == ''"
ResourceName="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed"
FormatArguments="PublishReadyToRun"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public TestProject([CallerMemberName] string name = null)
public List<TestPackageReference> PackageReferences { get; } = new List<TestPackageReference>();

public List<TestPackageReference> DotNetCliToolReferences { get; } = new List<TestPackageReference>();

public List<CopyFilesTarget> CopyFilesTargets { get; } = new List<CopyFilesTarget>();

public Dictionary<string, string> SourceFiles { get; } = new Dictionary<string, string>();
Expand All @@ -60,7 +60,7 @@ public TestProject([CallerMemberName] string name = null)

public Dictionary<string, string> AdditionalProperties { get; } = new Dictionary<string, string>();

public List<KeyValuePair<string, Dictionary<string, string>>> AdditionalItems { get; } = new();
public List<KeyValuePair<string, Dictionary<string, string>>> AdditionalItems { get; } = new ();

public List<Action<XDocument>> ProjectChanges { get; } = new List<Action<XDocument>>();

Expand Down Expand Up @@ -299,7 +299,7 @@ internal void Create(TestAsset targetTestAsset, string testProjectsSourceFolder,
new XAttribute("Include", frameworkReference)));
}
}

if (this.CopyFilesTargets.Any())
{
foreach (var copyFilesTarget in CopyFilesTargets)
Expand Down Expand Up @@ -443,7 +443,7 @@ public class {safeThisName}Class

public void AddItem(string itemName, string attributeName, string attributeValue)
{
AddItem(itemName, new Dictionary<string, string>() { { attributeName, attributeValue } });
AddItem(itemName, new Dictionary<string, string>() { { attributeName, attributeValue } } );
}

public void AddItem(string itemName, Dictionary<string, string> attributes)
Expand All @@ -458,28 +458,15 @@ public void RecordProperties(params string[] propertyNames)

public Dictionary<string, string> GetPropertyValues(string testRoot, string configuration = "Debug", string targetFramework = null, string runtimeIdentifier = null)
{
string finalOutputPath = Path.Combine(testRoot, Name, "obj", configuration, targetFramework ?? TargetFrameworks);
var propertyValues = new Dictionary<string, string>();

string intermediateOutputPath = Path.Combine(testRoot, Name, "obj", configuration, targetFramework ?? TargetFrameworks);
if (!string.IsNullOrEmpty(runtimeIdentifier))
{
finalOutputPath = Path.Combine(finalOutputPath, runtimeIdentifier);
intermediateOutputPath = Path.Combine(intermediateOutputPath, runtimeIdentifier);
}

return GetPropertyValues(finalOutputPath);
}

/// <summary>
/// Returns a dictionary of property name to value mappings.
/// </summary>
/// <param name="finalOutputPath">
/// The final output path after executing a dotnet command where propertyvalues.txt will be generated.
/// If the output path does not need to be hardcoded, use the overload requesting testRoot instead.
/// </param>
/// <returns></returns>
public Dictionary<string, string> GetPropertyValues(string finalOutputPath)
{
var propertyValues = new Dictionary<string, string>();

foreach (var line in File.ReadAllLines(Path.Combine(finalOutputPath, "PropertyValues.txt")))
foreach (var line in File.ReadAllLines(Path.Combine(intermediateOutputPath, "PropertyValues.txt")))
{
int colonIndex = line.IndexOf(':');
if (colonIndex > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,7 @@ public void PublishSelfContainedPropertyDoesOrDoesntOverrideSelfContained(bool p
.Should()
.Pass();

var publishedDirectory = testAsset.TestRoot;
publishedDirectory = Path.Combine(publishedDirectory, "MainProject", "obj", "Debug", targetFramework);
if (resultShouldBeSelfContained)
publishedDirectory = Directory.GetDirectories(publishedDirectory).FirstOrDefault(); // get the rid in the directory
var properties = testProject.GetPropertyValues(publishedDirectory.ToString());
var properties = testProject.GetPropertyValues(testAsset.TestRoot, targetFramework: targetFramework);

if (resultShouldBeSelfContained)
{
Expand Down

0 comments on commit a6e5ce0

Please sign in to comment.