Skip to content

Commit cd4d6e2

Browse files
committed
Respond to PR feedback of marking them all currentTFM and cleaning up how we set the target
1 parent b52b27b commit cd4d6e2

File tree

6 files changed

+24
-30
lines changed

6 files changed

+24
-30
lines changed

src/Assets/TestProjects/NetCoreCppCliLibWithTransitiveDeps/NETCoreCppCliTest/NETCoreCppCliTest.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<PropertyGroup Label="Globals">
3838
<VCProjectVersion>16.0</VCProjectVersion>
3939
<ProjectGuid>{CF5DA8D7-1FDF-4E8F-AFE6-450BE16E906A}</ProjectGuid>
40-
<TargetFramework>net5.0</TargetFramework>
40+
<TargetFramework>$(CurrentTargetFramework)</TargetFramework>
4141
<Keyword>ManagedCProj</Keyword>
4242
<EnableDynamicLoading>true</EnableDynamicLoading>
4343
<RootNamespace>NETCoreCppCliTest</RootNamespace>

src/Assets/TestProjects/NetCoreCppCliLibWithTransitiveDeps/NETCoreCppCliTestB/NETCoreCppCliTestB.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<PropertyGroup Label="Globals">
3838
<VCProjectVersion>16.0</VCProjectVersion>
3939
<ProjectGuid>{C8D22D0F-0C2D-4B4A-BF28-14A2D001102B}</ProjectGuid>
40-
<TargetFramework>net5.0</TargetFramework>
40+
<TargetFramework>$(CurrentTargetFramework)</TargetFramework>
4141
<Keyword>ManagedCProj</Keyword>
4242
<EnableDynamicLoading>true</EnableDynamicLoading>
4343
<RootNamespace>NETCoreCppCliTest</RootNamespace>

src/Assets/TestProjects/NetCoreCppCliLibWithTransitiveDeps/NETCoreCppCliTestC/NETCoreCppCliTestC.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<PropertyGroup Label="Globals">
3838
<VCProjectVersion>16.0</VCProjectVersion>
3939
<ProjectGuid>{73B24404-97DE-467A-8251-6542819BCEB4}</ProjectGuid>
40-
<TargetFramework>net5.0</TargetFramework>
40+
<TargetFramework>$(CurrentTargetFramework)</TargetFramework>
4141
<Keyword>ManagedCProj</Keyword>
4242
<EnableDynamicLoading>true</EnableDynamicLoading>
4343
<RootNamespace>NETCoreCppCliTest</RootNamespace>

src/Assets/TestProjects/NetCoreCsharpAppReferenceCppCliLib/CSConsoleApp/CSConsoleApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>$(CurrentTargetFramework)</TargetFramework>
55
<Platforms>x64</Platforms>
66
<PlatformTarget>x64</PlatformTarget>
77
</PropertyGroup>

src/Assets/TestProjects/NetCoreCsharpAppReferenceCppCliLib/NETCoreCppCliTest/NETCoreCppCliTest.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PropertyGroup Label="Globals">
1414
<VCProjectVersion>17.0</VCProjectVersion>
1515
<ProjectGuid>{CF5DA8D7-1FDF-4E8F-AFE6-450BE16E906A}</ProjectGuid>
16-
<TargetFramework>net7.0</TargetFramework>
16+
<TargetFramework>$(CurrentTargetFramework)</TargetFramework>
1717
<Keyword>ManagedCProj</Keyword>
1818
<RootNamespace>NETCoreCppCliTest</RootNamespace>
1919
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>

src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildACppCliProject.cs

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ public void It_builds_and_runs_with_package_reference()
6666
.WithSource()
6767
.WithProjectChanges((projectPath, project) => ConfigureProject(projectPath, project, "NewtonSoft.Json","13.0.1", targetFramework, new string[] { "_EnablePackageReferencesInVCProjects" , "IncludeWindowsSDKRefFrameworkReferences" }));
6868

69-
// build projects separately with BuildProjectReferences=false to simulate VS build behavior
7069
new BuildCommand(testAsset, "NETCoreCppCliTest")
71-
.Execute("-p:Platform=x64", "-p:EnableManagedpackageReferenceSupport=true", "/bl")
70+
.Execute("-p:Platform=x64", "-p:EnableManagedpackageReferenceSupport=true")
7271
.Should()
7372
.Pass();
7473

@@ -214,34 +213,29 @@ private void RecordProperties(string projectPath, XDocument project, string[] pr
214213
{
215214
if (Path.GetExtension(projectPath) == ".vcxproj")
216215
{
217-
List<XElement> propertiesElements = new List<XElement>();
216+
string propertiesTextElements = "";
218217
XNamespace ns = project.Root.Name.Namespace;
219218
foreach (var propertyName in properties)
220219
{
221-
propertiesElements.Add( new XElement(ns + "LinesToWrite", new XAttribute("Include", @$"{ propertyName }: $({ propertyName })")));
220+
propertiesTextElements += $" <LinesToWrite Include='{propertyName}: $({propertyName})'/>" + Environment.NewLine;
222221
}
223222

224-
// string target = $@"<Target Name='WritePropertyValues' BeforeTargets='AfterBuild'>
225-
// <ItemGroup>
226-
//{propertiesElements}
227-
// </ItemGroup>
228-
// <WriteLinesToFile
229-
// File='$(BaseIntermediateOutputPath)\$(Configuration)\$(TargetFramework)\PropertyValues.txt'
230-
// Lines='@(LinesToWrite)'
231-
// Overwrite='true'
232-
// Encoding='Unicode'
233-
// />
234-
// </Target>";
235-
XElement newNode = new XElement(ns + "Target",new XAttribute("Name","WriteProperty"), new XAttribute("BeforeTargets", "AfterBuild"),
236-
new XElement(ns + "ItemGroup",
237-
propertiesElements),
238-
new XElement(ns + "WriteLinesToFile",
239-
new XAttribute("File", @"$(BaseIntermediateOutputPath)\$(Configuration)\$(TargetFramework)\PropertyValues.txt"),
240-
new XAttribute("Lines", "@(LinesToWrite)"),
241-
new XAttribute("Overwrite","true"),
242-
new XAttribute("Encoding","Unicode")));
243-
244-
223+
string target = $@"<Target Name='WritePropertyValues' BeforeTargets='AfterBuild'>
224+
<ItemGroup>
225+
{propertiesTextElements}
226+
</ItemGroup>
227+
<WriteLinesToFile
228+
File='$(BaseIntermediateOutputPath)\$(Configuration)\$(TargetFramework)\PropertyValues.txt'
229+
Lines='@(LinesToWrite)'
230+
Overwrite='true'
231+
Encoding='Unicode'
232+
/>
233+
</Target>";
234+
XElement newNode = XElement.Parse(target);
235+
foreach (var element in newNode.DescendantsAndSelf())
236+
{
237+
element.Name = ns + element.Name.LocalName;
238+
}
245239
project.Root.AddFirst(newNode);
246240
}
247241
}

0 commit comments

Comments
 (0)