Skip to content

Commit 563463d

Browse files
committed
PR feedback: Use negative tests for IncludePackageReferencesDuringMarkupCompilation. Rename GenerateTemporaryTargetAssembly task. Add comment on porting source for GetRelativePath implementation.
1 parent 3e1aa9c commit 563463d

File tree

4 files changed

+35
-38
lines changed

4 files changed

+35
-38
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/PathInternal.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
// the difference. The method uses the default file path comparison for the
1212
// current platform (StringComparison.OrdinalIgnoreCase for Windows.)
1313
//
14+
// Ported to .NET Framework from the GetRelativePath implementation in:
15+
//
16+
// https://github.com/dotnet/corefx/blob/b123ba4b9107c73cbc02010dc1ee78eb8ffccb93/src/Common/src/CoreLib/System/IO/Path.cs
17+
//
18+
// This ported method ('GetRelativePath') is only called by the .NET Framework
19+
// version of PresentationBuildTasks.dll that ships with the Microsoft.NET.Sdk.WindowsDesktop
20+
// SDK as part of .NET 5.0.
21+
//
1422
//---------------------------------------------------------------------------
1523

1624
#pragma warning disable 1634, 1691

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
<UsingTask TaskName="Microsoft.Build.Tasks.Windows.FileClassifier" AssemblyFile="$(_PresentationBuildTasksAssembly)" />
1313
<UsingTask TaskName="Microsoft.Build.Tasks.Windows.MarkupCompilePass2" AssemblyFile="$(_PresentationBuildTasksAssembly)" />
1414
<UsingTask TaskName="Microsoft.Build.Tasks.Windows.GenerateTemporaryTargetAssembly" AssemblyFile="$(_PresentationBuildTasksAssembly)" />
15-
<UsingTask TaskName="Microsoft.Build.Tasks.Windows.GenerateTemporaryTargetAssembly2" AssemblyFile="$(_PresentationBuildTasksAssembly)" />
15+
<UsingTask TaskName="Microsoft.Build.Tasks.Windows.CompileTemporaryTargetAssembly" AssemblyFile="$(_PresentationBuildTasksAssembly)" />
1616
<UsingTask TaskName="Microsoft.Build.Tasks.Windows.CreateTemporaryTargetAssemblyProject" AssemblyFile="$(_PresentationBuildTasksAssembly)" />
1717
<UsingTask TaskName="Microsoft.Build.Tasks.Windows.MergeLocalizationDirectives" AssemblyFile="$(_PresentationBuildTasksAssembly)" />
1818

1919
<PropertyGroup>
20-
<IncludePackageReferencesDuringMarkupCompilation Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' == ''">true</IncludePackageReferencesDuringMarkupCompilation>
2120
<AlwaysCompileMarkupFilesInSeparateDomain Condition="'$(BuildingInsideVisualStudio)' == 'true' and '$(AlwaysCompileMarkupFilesInSeparateDomain)' == ''">true</AlwaysCompileMarkupFilesInSeparateDomain>
2221
<AlwaysCompileMarkupFilesInSeparateDomain Condition="'$(AlwaysCompileMarkupFilesInSeparateDomain)' == '' ">true</AlwaysCompileMarkupFilesInSeparateDomain>
2322
<LocalizationDirectivesToLocFile Condition="'$(LocalizationDirectivesToLocFile)' == ''">None</LocalizationDirectivesToLocFile>
@@ -382,15 +381,15 @@
382381
<MarkupCompilePass2ForMainAssemblyDependsOn>
383382
_CreateTemporaryTargetAssemblyProject;
384383
GenerateTemporaryTargetAssembly;
385-
_GenerateTemporaryTargetAssembly2;
384+
_CompileTemporaryTargetAssembly;
386385
MarkupCompilePass2;
387386
AfterMarkupCompilePass2;
388387
CleanupTemporaryTargetAssembly
389388
</MarkupCompilePass2ForMainAssemblyDependsOn>
390389

391390
<_CompileTargetNameForLocalType Condition="'$(_CompileTargetNameForLocalType)' == ''">_CompileTemporaryAssembly</_CompileTargetNameForLocalType>
392391

393-
<_ResolveProjectReferencesTargetName Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' == 'true'">ResolveProjectReferences</_ResolveProjectReferencesTargetName>
392+
<_ResolveProjectReferencesTargetName Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' != 'false'">ResolveProjectReferences</_ResolveProjectReferencesTargetName>
394393
<_CompileTemporaryAssemblyDependsOn>BuildOnlySettings;ResolveKeySource;$(_ResolveProjectReferencesTargetName);CoreCompile</_CompileTemporaryAssemblyDependsOn>
395394

396395
</PropertyGroup>
@@ -406,13 +405,13 @@
406405

407406
<!--
408407
==========================================
409-
CreateTemporaryTargetAssemblyProject
408+
_CreateTemporaryTargetAssemblyProject
410409
==========================================
411-
Name : CreateTemporaryTargetAssemblyProject
410+
Name : _CreateTemporaryTargetAssemblyProject
412411
-->
413412

414-
<Target Name="CreateTemporaryTargetAssemblyProject"
415-
Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' == 'true' and '$(_RequireMCPass2ForMainAssembly)' == 'true'" >
413+
<Target Name="_CreateTemporaryTargetAssemblyProject"
414+
Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' != 'false' and '$(_RequireMCPass2ForMainAssembly)' == 'true'" >
416415

417416
<CreateTemporaryTargetAssemblyProject
418417
CurrentProject="$(MSBuildProjectFullPath)"
@@ -497,19 +496,19 @@
497496
<!--
498497
499498
==========================================
500-
GenerateTemporaryTargetAssembly2
499+
_CompileTemporaryTargetAssembly
501500
==========================================
502501
503-
Name : GenerateTemporaryTargetAssembly2
502+
Name : _CompileTemporaryTargetAssembly
504503
505504
-->
506505

507-
<Target Name="GenerateTemporaryTargetAssembly2"
508-
Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' == 'true' and '$(_RequireMCPass2ForMainAssembly)' == 'true'" >
506+
<Target Name="_CompileTemporaryTargetAssembly"
507+
Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' != 'false' and '$(_RequireMCPass2ForMainAssembly)' == 'true'" >
509508

510509
<Message Text="MSBuildProjectFile is $(MSBuildProjectFile)" Condition="'$(MSBuildTargetsVerbose)' == 'true'" />
511510

512-
<GenerateTemporaryTargetAssembly2
511+
<CompileTemporaryTargetAssembly
513512
CurrentProject="$(MSBuildProjectFullPath)"
514513
MSBuildBinPath="$(MSBuildBinPath)"
515514
ReferencePathTypeName="ReferencePath"
@@ -523,7 +522,7 @@
523522
GenerateTemporaryTargetAssemblyDebuggingInformation="$(GenerateTemporaryTargetAssemblyDebuggingInformation)"
524523
>
525524

526-
</GenerateTemporaryTargetAssembly2>
525+
</CompileTemporaryTargetAssembly>
527526

528527
<CreateItem Include="$(IntermediateOutputPath)$(TargetFileName)" >
529528
<Output TaskParameter="Include" ItemName="AssemblyForLocalTypeReference" />
Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44

55
//---------------------------------------------------------------------------
66
//
7-
// Description: This is a MSBuild task which generates a temporary target assembly
8-
// if current project contains a xaml file with local-type-reference.
7+
// Description: This is a MSBuild task which compiles a temporary target assembly
8+
// from a project generated by the CreateTemporaryTargetAssemblyProject
9+
// task, if the current project contains a xaml file with
10+
// local-type-reference.
911
//
10-
// It generates a temporary project file and then call build-engine
11-
// to compile it.
12+
// It calls the build-engine to compile the temporary target assembly
13+
// project.
1214
//
13-
// The new project file will replace all the Reference Items with the
14-
// resolved ReferencePath, add all the generated code file into Compile
15-
// Item list.
16-
//
1715
//---------------------------------------------------------------------------
1816

1917
using System;
@@ -38,22 +36,14 @@
3836

3937
namespace Microsoft.Build.Tasks.Windows
4038
{
41-
#region GenerateTemporaryTargetAssembly2 Task class
39+
#region CompileTemporaryTargetAssembly Task class
4240

4341
/// <summary>
44-
/// This task is used to generate a temporary target assembly. It generates
45-
/// a temporary project file and then compile it.
46-
///
47-
/// The generated project file is based on current project file, with below
48-
/// modification:
49-
///
50-
/// A: Add the generated code files (.g.cs) to Compile Item list.
51-
/// B: Replace Reference Item list with ReferenctPath item list.
52-
/// So that it doesn't need to rerun time-consuming task
53-
/// ResolveAssemblyReference (RAR) again.
54-
///
42+
/// This task is used to compile a temporary assembly from the
43+
/// project file generated by the CreateTemporaryTargetAssemblyProject
44+
/// task.
5545
/// </summary>
56-
public sealed class GenerateTemporaryTargetAssembly2 : Task
46+
public sealed class CompileTemporaryTargetAssembly : Task
5747
{
5848
//------------------------------------------------------
5949
//
@@ -66,7 +56,7 @@ public sealed class GenerateTemporaryTargetAssembly2 : Task
6656
/// <summary>
6757
/// Constructor
6858
/// </summary>
69-
public GenerateTemporaryTargetAssembly2()
59+
public CompileTemporaryTargetAssembly()
7060
: base(SR.SharedResourceManager)
7161
{
7262
}
@@ -328,5 +318,5 @@ public bool GenerateTemporaryTargetAssemblyDebuggingInformation
328318

329319
}
330320

331-
#endregion GenerateTemporaryTargetAssembly2 Task class
321+
#endregion CompileTemporaryTargetAssembly Task class
332322
}

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/PresentationBuildTasks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@
300300
<Compile Include="Microsoft\Build\Tasks\Windows\UpdateManifestForBrowserApplication.cs" />
301301
<Compile Include="Microsoft\Build\Tasks\Windows\ResourcesGenerator.cs" />
302302
<Compile Include="Microsoft\Build\Tasks\Windows\GenerateTemporaryTargetAssembly.cs" />
303-
<Compile Include="Microsoft\Build\Tasks\Windows\GenerateTemporaryTargetAssembly2.cs" />
303+
<Compile Include="Microsoft\Build\Tasks\Windows\CompileTemporaryTargetAssembly.cs" />
304304
<Compile Include="Microsoft\Build\Tasks\Windows\CreateTemporaryTargetAssemblyProject.cs" />
305305
</ItemGroup>
306306

0 commit comments

Comments
 (0)