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

Support PackageReferences in WPF projects #3585

Merged
merged 11 commits into from
Nov 7, 2020
Merged
Show file tree
Hide file tree
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 @@ -1576,9 +1576,9 @@ private string ParentFolderPrefix
get
{
#if NETFX
return PathInternal.GetRelativePath(TargetPath, SourceFileInfo.SourcePath, StringComparison.OrdinalIgnoreCase);
return PathInternal.GetRelativePath(TargetPath, SourceFileInfo.SourcePath, StringComparison.OrdinalIgnoreCase) + Path.DirectorySeparatorChar;
#else
return Path.GetRelativePath(TargetPath, SourceFileInfo.SourcePath);
return Path.GetRelativePath(TargetPath, SourceFileInfo.SourcePath) + Path.DirectorySeparatorChar;
#endif
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
<UsingTask TaskName="Microsoft.Build.Tasks.Windows.FileClassifier" AssemblyFile="$(_PresentationBuildTasksAssembly)" />
<UsingTask TaskName="Microsoft.Build.Tasks.Windows.MarkupCompilePass2" AssemblyFile="$(_PresentationBuildTasksAssembly)" />
<UsingTask TaskName="Microsoft.Build.Tasks.Windows.GenerateTemporaryTargetAssembly" AssemblyFile="$(_PresentationBuildTasksAssembly)" />
<UsingTask TaskName="Microsoft.Build.Tasks.Windows.GenerateTemporaryTargetAssembly2" AssemblyFile="$(_PresentationBuildTasksAssembly)" />
<UsingTask TaskName="Microsoft.Build.Tasks.Windows.CreateTemporaryTargetAssemblyProject" AssemblyFile="$(_PresentationBuildTasksAssembly)" />
ryalanms marked this conversation as resolved.
Show resolved Hide resolved
<UsingTask TaskName="Microsoft.Build.Tasks.Windows.MergeLocalizationDirectives" AssemblyFile="$(_PresentationBuildTasksAssembly)" />

<PropertyGroup>
<ShouldWPFSupportPackageReferences Condition="'$(ShouldWPFSupportPackageReferences)' == ''">true</ShouldWPFSupportPackageReferences>
<AlwaysCompileMarkupFilesInSeparateDomain Condition="'$(BuildingInsideVisualStudio)' == 'true' and '$(AlwaysCompileMarkupFilesInSeparateDomain)' == ''">true</AlwaysCompileMarkupFilesInSeparateDomain>
<AlwaysCompileMarkupFilesInSeparateDomain Condition="'$(AlwaysCompileMarkupFilesInSeparateDomain)' == '' ">true</AlwaysCompileMarkupFilesInSeparateDomain>
<LocalizationDirectivesToLocFile Condition="'$(LocalizationDirectivesToLocFile)' == ''">None</LocalizationDirectivesToLocFile>
Expand Down Expand Up @@ -377,18 +380,22 @@
<PropertyGroup>

<MarkupCompilePass2ForMainAssemblyDependsOn>
CreateTemporaryTargetAssemblyProject;
GenerateTemporaryTargetAssembly;
GenerateTemporaryTargetAssembly2;
MarkupCompilePass2;
AfterMarkupCompilePass2;
CleanupTemporaryTargetAssembly
</MarkupCompilePass2ForMainAssemblyDependsOn>

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

<_ResolveProjectReferencesTargetName Condition="'$(ShouldWPFSupportPackageReferences)' == 'true'">ResolveProjectReferences</_ResolveProjectReferencesTargetName>
<_CompileTemporaryAssemblyDependsOn>BuildOnlySettings;ResolveKeySource;$(_ResolveProjectReferencesTargetName);CoreCompile</_CompileTemporaryAssemblyDependsOn>

</PropertyGroup>

<Target Name="_CompileTemporaryAssembly" DependsOnTargets="BuildOnlySettings;ResolveKeySource;CoreCompile" />
<Target Name="_CompileTemporaryAssembly" DependsOnTargets="$(_CompileTemporaryAssemblyDependsOn)" />


<Target Name="MarkupCompilePass2ForMainAssembly"
Expand All @@ -397,6 +404,59 @@

</Target>

<!--
==========================================
CreateTemporaryTargetAssemblyProject
==========================================
Name : CreateTemporaryTargetAssemblyProject
-->

<Target Name="CreateTemporaryTargetAssemblyProject"
Condition="'$(ShouldWPFSupportPackageReferences)' == 'true' and '$(_RequireMCPass2ForMainAssembly)' == 'true'" >

<CreateTemporaryTargetAssemblyProject
CurrentProject="$(MSBuildProjectFullPath)"
GeneratedCodeFiles="@(_GeneratedCodeFiles)"
CompileTypeName="Compile"
ReferencePath="@(ReferencePath)"
ReferencePathTypeName="ReferencePath"
IntermediateOutputPath="$(IntermediateOutputPath)"
AssemblyName="$(AssemblyName)"
MSBuildProjectExtensionsPath="$(MSBuildProjectExtensionsPath)"
Analyzers="$(Analyzers)" >
<Output TaskParameter="TemporaryTargetAssemblyProjectName" PropertyName="_TemporaryTargetAssemblyProjectName"/>
</CreateTemporaryTargetAssemblyProject>

<Message Text="GenerateTemporaryTargetAssembyProject project is $(_TemporaryTargetAssemblyProjectName)" />

<!-- Path to generated NuGet props and targets files -->
<Message Text="MSBuildProjectExtensionsPath: $(MSBuildProjectExtensionsPath)" />

<!-- Get the name of the outer WPF parent project -->
<PropertyGroup>
<CurrentProjectName>$([System.IO.Path]::GetFileName('$(MSBuildProjectFullPath)'))</CurrentProjectName>
</PropertyGroup>

<!-- Collect the generated NuGet files from the parent project required support PackageReferences -->
<ItemGroup>
<SourceGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)\*.props"/>
<SourceGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)\*.targets"/>
<SourceGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)\*.dgspec.json"/>
<_DestinationGeneratedNuGetPropsAndTargets Include="@(SourceGeneratedNuGetPropsAndTargets->'%(RelativeDir)%(Filename)%(Extension)'->Replace('$(CurrentProjectName)', '$(_TemporaryTargetAssemblyProjectName)'))"/>
</ItemGroup>

<Message Text="Re-using generated NuGet props and targets from the parent project...)" />
<Message Text="SourceGeneratedNuGetPropsAndTargets source files: @(SourceGeneratedNuGetPropsAndTargets)" />
<Message Text="DestinationPropsAndTargets destination files: @(_DestinationGeneratedNuGetPropsAndTargets)" />

<!-- Copy the renamed outer project NuGet props/targets files to the MSBuildProjectExtensionsPath used by NuGet -->
<Copy
SourceFiles="@(SourceNuGetPropsAndTargets)"
DestinationFiles="@(_DestinationGeneratedNuGetPropsAndTargets)"
/>

</Target>


<!--

Expand All @@ -409,7 +469,7 @@
-->

<Target Name="GenerateTemporaryTargetAssembly"
Condition="'$(_RequireMCPass2ForMainAssembly)' == 'true' " >
Condition="'$(ShouldWPFSupportPackageReferences)' == 'false' And '$(_RequireMCPass2ForMainAssembly)' == 'true'" >

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

Expand All @@ -432,6 +492,46 @@
<Output TaskParameter="Include" ItemName="AssemblyForLocalTypeReference" />
</CreateItem>

</Target>

<!--

==========================================
GenerateTemporaryTargetAssembly2
==========================================

Name : GenerateTemporaryTargetAssembly2

-->

<Target Name="GenerateTemporaryTargetAssembly2"
Condition="'$(ShouldWPFSupportPackageReferences)' == 'true' and '$(_RequireMCPass2ForMainAssembly)' == 'true'" >

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

<GenerateTemporaryTargetAssembly2
CurrentProject="$(MSBuildProjectFullPath)"
MSBuildBinPath="$(MSBuildBinPath)"
ReferencePathTypeName="ReferencePath"
CompileTypeName="Compile"
GeneratedCodeFiles="@(_GeneratedCodeFiles)"
ReferencePath="@(ReferencePath)"
IntermediateOutputPath="$(IntermediateOutputPath)"
AssemblyName="$(AssemblyName)"
TemporaryTargetAssemblyProjectName="$(_TemporaryTargetAssemblyProjectName)"
CompileTargetName="$(_CompileTargetNameForLocalType)"
GenerateTemporaryTargetAssemblyDebuggingInformation="$(GenerateTemporaryTargetAssemblyDebuggingInformation)"
>

</GenerateTemporaryTargetAssembly2>

<CreateItem Include="$(IntermediateOutputPath)$(TargetFileName)" >
<Output TaskParameter="Include" ItemName="AssemblyForLocalTypeReference" />
</CreateItem>

<Message Text="Deleting generated NuGet props and targets files from the temporary project: @(_DestinationGeneratedNuGetPropsAndTargets)"/>
<Delete Files="@(_DestinationGeneratedNuGetPropsAndTargets)"/>

</Target>


Expand Down
Loading