Skip to content

Commit

Permalink
NuGet: Set EnableWindowsTargeting as true (#9082)
Browse files Browse the repository at this point in the history
* Set EnableWindowsTargeting

* Revert "Set EnableWindowsTargeting"

This reverts commit b45ddf5.

* Add EnableWindowsTargeting in temp project

* Add Test case

---------

Co-authored-by: AbdulFattaah Popoola <abdulapopoola@github.com>
Co-authored-by: Nish Sinha <nishnha@github.com>
  • Loading branch information
3 people committed Feb 21, 2024
1 parent c0ef96f commit 97e8329
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,38 @@ public async Task UpdateVersionAttribute_InProjectFile_ForPackageReferenceInclud
""");
}

[Fact]
public async Task UpdateVersionAttribute_InProjectFile_ForPackageReferenceInclude_Windows()
{
// update Newtonsoft.Json from 9.0.1 to 13.0.1
await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
// initial
projectContents: $"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>
</Project>
""",
// expected
expectedProjectContents: $"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>
""");
}

[Theory]
[InlineData("$(NewtonsoftJsonVersion")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,17 @@ private static ProjectRootElement CreateProjectRootElement(ProjectBuildFile buil
await File.WriteAllTextAsync(tempProjectPath, projectContents);

// prevent directory crawling
await File.WriteAllTextAsync(Path.Combine(tempDir.FullName, "Directory.Build.props"), "<Project />");
await File.WriteAllTextAsync(
Path.Combine(tempDir.FullName, "Directory.Build.props"),
"""
<Project>
<PropertyGroup>
<!-- For Windows-specific apps -->
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>
</Project>
""");

await File.WriteAllTextAsync(Path.Combine(tempDir.FullName, "Directory.Build.targets"), "<Project />");
await File.WriteAllTextAsync(Path.Combine(tempDir.FullName, "Directory.Packages.props"), "<Project />");

Expand Down

0 comments on commit 97e8329

Please sign in to comment.