Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check contentFiles and different alias inference #3686

Merged
merged 1 commit into from
Sep 29, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public void PackTaskLogic_InfersFrameworkPlatformVersionFromAlias()
// Arrange
using (var testDir = TestDirectory.Create())
{
var tc = new TestContext(testDir, "net5.0-windows");
var tc = new TestContext(testDir, "net50-windows");

var assetsJson = @"{
""version"": 3,
Expand All @@ -530,7 +530,7 @@ public void PackTaskLogic_InfersFrameworkPlatformVersionFromAlias()
],
""originalTargetFrameworks"": [
""net5.0"",
""net5.0-windows""
""net50-windows""
],
""sources"": {
""https://api.nuget.org/v3/index.json"": {},
Expand All @@ -541,7 +541,7 @@ public void PackTaskLogic_InfersFrameworkPlatformVersionFromAlias()
""projectReferences"": {}
},
""net5.0-windows7.0"": {
""targetAlias"": ""net5.0-windows"",
""targetAlias"": ""net50-windows"",
""projectReferences"": {}
}
},
Expand Down Expand Up @@ -571,7 +571,7 @@ public void PackTaskLogic_InfersFrameworkPlatformVersionFromAlias()
},
},
""net5.0-windows7.0"": {
""targetAlias"": ""net5.0-windows"",
""targetAlias"": ""net50-windows"",
""imports"": [
""net461"",
""net462"",
Expand All @@ -593,9 +593,19 @@ public void PackTaskLogic_InfersFrameworkPlatformVersionFromAlias()
}";
File.WriteAllText(Path.Combine(testDir, "obj", "project.assets.json"), assetsJson);

// var msbuildItem = tc.AddContentToProject("", "abc.txt", "hello world");
// tc.Request.PackageFiles = new MSBuildItem[] { msbuildItem };
// tc.Request.ContentTargetFolders = new string[] { "content" };
tc.Request.PackageFiles = new MSBuildItem[] {
tc.AddContentToProject("", "abc.txt", "hello world", new Dictionary<string, string>()
{
{"BuildAction", "Content"}
}),
tc.AddContentToProject("", "def.txt", "hello world", new Dictionary<string, string>()
{
{"BuildAction", "None"},
{"Pack", "true" },
{"PackagePath", "contentFiles\\net5.0-windows" }
})
};
tc.Request.ContentTargetFolders = new string[] { "content", "contentFiles" };

// Act
tc.BuildPackage();
Expand All @@ -610,6 +620,23 @@ public void PackTaskLogic_InfersFrameworkPlatformVersionFromAlias()
Assert.Equal(1, libItems.Count);
Assert.Equal(NuGetFramework.Parse("net5.0-windows7.0"), libItems[0].TargetFramework);
Assert.Equal(new[] { "lib/net5.0-windows7.0/a.dll" }, libItems[0].Items);

var contentFiles = nuspecReader.GetContentFiles().ToList();

Assert.Equal(contentFiles.Count, 2);
Assert.Equal(contentFiles[0].BuildAction, "Content", StringComparer.Ordinal);
Assert.Equal(contentFiles[0].Include, "any/net5.0-windows7.0/abc.txt", StringComparer.Ordinal);
Assert.Equal(contentFiles[1].BuildAction, "None", StringComparer.Ordinal);
Assert.Equal(contentFiles[1].Include, "net5.0-windows/def.txt", StringComparer.Ordinal);

// Validate the content items
var contentItems = nupkgReader.GetFiles("content").ToList();
var contentFileItems = nupkgReader.GetFiles("contentFiles").ToList();
Assert.Equal(contentItems.Count, 1);
Assert.Equal(contentFileItems.Count, 2);
Assert.Contains("content/abc.txt", contentItems, StringComparer.Ordinal);
Assert.Contains("contentFiles/any/net5.0-windows7.0/abc.txt", contentFileItems, StringComparer.Ordinal);
Assert.Contains("contentFiles/net5.0-windows/def.txt", contentFileItems, StringComparer.Ordinal);
}
}
}
Expand Down