|
383 | 383 | CleanupTemporaryTargetAssembly
|
384 | 384 | </MarkupCompilePass2ForMainAssemblyDependsOn>
|
385 | 385 |
|
386 |
| - <_CompileTargetNameForLocalType Condition="'$(_CompileTargetNameForLocalType)' == ''">_CompileTemporaryAssembly</_CompileTargetNameForLocalType> |
| 386 | + <_CompileTargetNameForLocalType Condition="'$(_CompileTargetNameForLocalType)' == ''">_CompileTemporaryAssembly</_CompileTargetNameForLocalType> |
387 | 387 |
|
| 388 | + <!-- The updated .NET 5.0.2 GenerateTemporaryTargetAssembly behavior that supports source generators is off by default. --> |
| 389 | + <IncludePackageReferencesDuringMarkupCompilation Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' == ''">false</IncludePackageReferencesDuringMarkupCompilation> |
| 390 | + <_ResolveProjectReferencesTargetName Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' != 'false'">ResolveProjectReferences</_ResolveProjectReferencesTargetName> |
| 391 | + <_CompileTemporaryAssemblyDependsOn>BuildOnlySettings;ResolveKeySource;$(_ResolveProjectReferencesTargetName);CoreCompile</_CompileTemporaryAssemblyDependsOn> |
388 | 392 |
|
389 | 393 | </PropertyGroup>
|
390 | 394 |
|
391 |
| - <Target Name="_CompileTemporaryAssembly" DependsOnTargets="BuildOnlySettings;ResolveKeySource;CoreCompile" /> |
| 395 | + <Target Name="_CompileTemporaryAssembly" DependsOnTargets="$(_CompileTemporaryAssemblyDependsOn)" /> |
392 | 396 |
|
393 | 397 |
|
394 | 398 | <Target Name="MarkupCompilePass2ForMainAssembly"
|
|
397 | 401 |
|
398 | 402 | </Target>
|
399 | 403 |
|
400 |
| - |
401 | 404 | <!--
|
402 | 405 |
|
403 | 406 | ==========================================
|
|
407 | 410 | Name : GenerateTemporaryTargetAssembly
|
408 | 411 |
|
409 | 412 | -->
|
| 413 | + <Target Name="GenerateTemporaryTargetAssembly" Condition="'$(_RequireMCPass2ForMainAssembly)' == 'true'"> |
| 414 | + |
| 415 | + <Message Text="MSBuildProjectFile is $(MSBuildProjectFile)" Condition="'$(MSBuildTargetsVerbose)' == 'true'" /> |
| 416 | + |
| 417 | + <!-- Create a temporary target assembly project name with a random component. --> |
| 418 | + <PropertyGroup Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' != 'false'"> |
| 419 | + <_ParentProjectName>$([System.IO.Path]::GetFileNameWithoutExtension('$(MSBuildProjectFullPath)'))</_ParentProjectName> |
| 420 | + <_ParentProjectExtension>$([System.IO.Path]::GetExtension($(MSBuildProjectFullPath)))</_ParentProjectExtension> |
| 421 | + <_TemporaryTargetAssemblyProjectNameNoExtension>$([System.String]::Join("_", "$(_ParentProjectName)", "$([System.IO.Path]::GetFileNameWithoutExtension($([System.IO.Path]::GetRandomFileName())))", "wpftmp"))</_TemporaryTargetAssemblyProjectNameNoExtension> |
| 422 | + <_TemporaryTargetAssemblyProjectName>$(_TemporaryTargetAssemblyProjectNameNoExtension)$(_ParentProjectExtension)</_TemporaryTargetAssemblyProjectName> |
| 423 | + </PropertyGroup> |
| 424 | + |
| 425 | + <!-- Collect the generated NuGet files from the parent project required to support PackageReferences. --> |
| 426 | + <ItemGroup Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' != 'false'"> |
| 427 | + <_SourceGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_ParentProjectName)$(_ParentProjectExtension).nuget.g.props"/> |
| 428 | + <_SourceGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_ParentProjectName)$(_ParentProjectExtension).nuget.g.targets"/> |
| 429 | + <_SourceGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_ParentProjectName)$(_ParentProjectExtension).nuget.dgspec.json"/> |
| 430 | + |
| 431 | + <_DestGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_TemporaryTargetAssemblyProjectName).nuget.g.props"/> |
| 432 | + <_DestGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_TemporaryTargetAssemblyProjectName).nuget.g.targets"/> |
| 433 | + <_DestGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_TemporaryTargetAssemblyProjectName).nuget.dgspec.json"/> |
| 434 | + |
| 435 | + </ItemGroup> |
| 436 | + |
| 437 | + <!-- Copy the renamed outer project NuGet props/targets files to the MSBuildProjectExtensionsPath used by NuGet. --> |
| 438 | + <Copy Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' != 'false'" |
| 439 | + SourceFiles="@(_SourceGeneratedNuGetPropsAndTargets)" |
| 440 | + DestinationFiles="@(_DestGeneratedNuGetPropsAndTargets)" |
| 441 | + /> |
410 | 442 |
|
411 |
| - <Target Name="GenerateTemporaryTargetAssembly" |
412 |
| - Condition="'$(_RequireMCPass2ForMainAssembly)' == 'true' " > |
| 443 | + <!-- |
| 444 | + Undo TargetFramework and RID append set in Microsoft.NET.RuntimeIdentifierInference.targets to prevent |
| 445 | + a duplicate target framework and runtime identifier in the IntermediateOutputPath when the new BuildEngine |
| 446 | + instance runs. |
413 | 447 |
|
414 |
| - <Message Text="MSBuildProjectFile is $(MSBuildProjectFile)" Condition="'$(MSBuildTargetsVerbose)' == 'true'" /> |
| 448 | + 'Append $(RuntimeIdentifier) to directory to output and intermediate paths to prevent bin clashes between |
| 449 | + targets. But do not append the implicit default runtime identifier for .NET Framework apps as that would |
| 450 | + append a RID the user never mentioned in the path and do so even in the AnyCPU case.' |
| 451 | + --> |
415 | 452 |
|
| 453 | + <PropertyGroup> |
| 454 | + <_IntermediateOutputPathNoTargetFrameworkOrRID>$(IntermediateOutputPath)</_IntermediateOutputPathNoTargetFrameworkOrRID> |
| 455 | + </PropertyGroup> |
| 456 | + |
| 457 | + <PropertyGroup Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' != 'false' and |
| 458 | + '$(AppendRuntimeIdentifierToOutputPath)' == 'true' and '$(RuntimeIdentifier)' != '' and |
| 459 | + '$(_UsingDefaultRuntimeIdentifier)' != 'true'"> |
| 460 | + <_IntermediateOutputPathNoTargetFrameworkOrRID>$([System.Text.RegularExpressions.Regex]::Replace($(_IntermediateOutputPathNoTargetFrameworkOrRID), "$(RuntimeIdentifier)\\$",, System.Text.RegularExpressions.RegexOptions.IgnoreCase))</_IntermediateOutputPathNoTargetFrameworkOrRID> |
| 461 | + </PropertyGroup> |
| 462 | + |
| 463 | + <PropertyGroup Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' != 'false' and |
| 464 | + '$(AppendTargetFrameworkToOutputPath)' == 'true' and '$(TargetFramework)' != '' and |
| 465 | + '$(_UnsupportedTargetFrameworkError)' != 'true'"> |
| 466 | + <_IntermediateOutputPathNoTargetFrameworkOrRID>$([System.Text.RegularExpressions.Regex]::Replace($(_IntermediateOutputPathNoTargetFrameworkOrRID), "$(TargetFramework)\\$",, System.Text.RegularExpressions.RegexOptions.IgnoreCase))</_IntermediateOutputPathNoTargetFrameworkOrRID> |
| 467 | + </PropertyGroup> |
| 468 | + |
| 469 | + <!-- Use the legacy .NET Framework/.NET Core 3.0 GenerateTemporaryTargetAssembly path if 'IncludePackageReferencesDuringMarkupCompilation' is 'false',. --> |
416 | 470 | <GenerateTemporaryTargetAssembly
|
417 | 471 | CurrentProject="$(MSBuildProjectFullPath)"
|
418 | 472 | MSBuildBinPath="$(MSBuildBinPath)"
|
419 | 473 | ReferencePathTypeName="ReferencePath"
|
420 | 474 | CompileTypeName="Compile"
|
421 | 475 | GeneratedCodeFiles="@(_GeneratedCodeFiles)"
|
422 | 476 | ReferencePath="@(ReferencePath)"
|
423 |
| - IntermediateOutputPath="$(IntermediateOutputPath)" |
| 477 | + BaseIntermediateOutputPath="$(BaseIntermediateOutputPath)" |
| 478 | + IntermediateOutputPath="$(_IntermediateOutputPathNoTargetFrameworkOrRID)" |
424 | 479 | AssemblyName="$(AssemblyName)"
|
425 | 480 | CompileTargetName="$(_CompileTargetNameForLocalType)"
|
426 | 481 | GenerateTemporaryTargetAssemblyDebuggingInformation="$(GenerateTemporaryTargetAssemblyDebuggingInformation)"
|
| 482 | + IncludePackageReferencesDuringMarkupCompilation="$(IncludePackageReferencesDuringMarkupCompilation)" |
| 483 | + Analyzers="$(Analyzers)" |
| 484 | + TemporaryTargetAssemblyProjectName="$(_TemporaryTargetAssemblyProjectName)" |
427 | 485 | >
|
428 | 486 |
|
429 | 487 | </GenerateTemporaryTargetAssembly>
|
|
432 | 490 | <Output TaskParameter="Include" ItemName="AssemblyForLocalTypeReference" />
|
433 | 491 | </CreateItem>
|
434 | 492 |
|
435 |
| - </Target> |
436 |
| - |
| 493 | + <!-- Remove generated NuGet props/targets files. --> |
| 494 | + <Delete |
| 495 | + Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' != 'false' |
| 496 | + and '$(GenerateTemporaryTargetAssemblyDebuggingInformation)' != 'true'" |
| 497 | + Files="@(_DestGeneratedNuGetPropsAndTargets)" /> |
| 498 | + |
| 499 | + </Target> |
437 | 500 |
|
438 | 501 | <!--
|
439 | 502 |
|
|
0 commit comments