From 09c971de400d01d066a411dcd0c3035f04af68ab Mon Sep 17 00:00:00 2001
From: Ryland <41491307+ryalanms@users.noreply.github.com>
Date: Mon, 18 Jan 2021 11:18:26 -0800
Subject: [PATCH 1/3] Make custom IntermediateOutputPath and
BaseIntermediateOutputPath support opt-in
---
.../Internal/MarkupCompiler/MarkupCompiler.cs | 30 +++++++++++++++++--
.../MS/Internal/Tasks/CompilerWrapper.cs | 5 ++++
.../MS/Internal/Tasks/TaskHelper.cs | 2 +-
.../Microsoft.WinFX.targets | 6 ++--
.../Build/Tasks/Windows/MarkupCompilePass1.cs | 9 +++++-
.../Build/Tasks/Windows/MarkupCompilePass2.cs | 9 +++++-
6 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs
index 556ea8e7850..13880279839 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs
@@ -154,6 +154,11 @@ internal TaskLoggingHelper TaskLogger
set { _taskLogger = value; }
}
+ ///
+ /// Support custom IntermediateOutputPath and BaseIntermediateOutputPath outside the project path
+ ///
+ internal bool SupportCustomOutputPaths { get; set; } = false;
+
// If the xaml has local references, then it could have internal element & properties
// but there is no way to determine this until MCPass2. Yet, GeneratedInternalTypeHelper,
// which is the class that allows access to legitimate internals, needs to be generated
@@ -1575,11 +1580,30 @@ private string ParentFolderPrefix
{
get
{
-#if NETFX
- return PathInternal.GetRelativePath(TargetPath, SourceFileInfo.SourcePath, StringComparison.OrdinalIgnoreCase) + Path.DirectorySeparatorChar;
+ if (SupportCustomOutputPaths)
+ {
+ #if NETFX
+ return PathInternal.GetRelativePath(TargetPath, SourceFileInfo.SourcePath, StringComparison.OrdinalIgnoreCase) + Path.DirectorySeparatorChar;
#else
- return Path.GetRelativePath(TargetPath, SourceFileInfo.SourcePath) + Path.DirectorySeparatorChar;
+ return Path.GetRelativePath(TargetPath, SourceFileInfo.SourcePath) + Path.DirectorySeparatorChar;
#endif
+ }
+ else
+ {
+ string parentFolderPrefix = string.Empty;
+ if (TargetPath.StartsWith(SourceFileInfo.SourcePath, StringComparison.OrdinalIgnoreCase))
+ {
+ string relPath = TargetPath.Substring(SourceFileInfo.SourcePath.Length);
+ relPath += SourceFileInfo.RelativeSourceFilePath;
+ string[] dirs = relPath.Split(new Char[] { Path.DirectorySeparatorChar });
+ for (int i = 1; i < dirs.Length; i++)
+ {
+ parentFolderPrefix += PARENTFOLDER;
+ }
+ }
+
+ return parentFolderPrefix;
+ }
}
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerWrapper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerWrapper.cs
index d47c9af6ff0..5ae45bc28d4 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerWrapper.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerWrapper.cs
@@ -201,6 +201,11 @@ internal int ErrorTimes
get { return _nErrors; }
}
+ internal bool SupportCustomOutputPaths
+ {
+ set { _mc.SupportCustomOutputPaths = value; }
+ }
+
//
// Start the compilation.
//
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/TaskHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/TaskHelper.cs
index e6808dd1266..527ec58082d 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/TaskHelper.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/TaskHelper.cs
@@ -223,7 +223,7 @@ internal static string GetWholeExceptionMessage(Exception exception)
//
// Helper to create CompilerWrapper.
//
- internal static CompilerWrapper CreateCompilerWrapper(bool fInSeparateDomain, ref AppDomain appDomain)
+ internal static CompilerWrapper CreateCompilerWrapper()
{
return new CompilerWrapper();
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets
index 32ba51576be..fe972e40db0 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets
@@ -244,7 +244,8 @@
ExtraBuildControlFiles="@(ExtraBuildControlFiles)"
XamlDebuggingInformation="$(XamlDebuggingInformation)"
IsRunningInVisualStudio="$(BuildingInsideVisualStudio)"
- OutputPath="$(IntermediateOutputPath)">
+ OutputPath="$(IntermediateOutputPath)"
+ SupportCustomOutputPaths="$(IncludePackageReferencesDuringMarkupCompilation)">
@@ -304,7 +305,8 @@
XamlDebuggingInformation="$(XamlDebuggingInformation)"
GeneratedBaml=""
OutputPath="$(IntermediateOutputPath)"
- ContinueOnError="false" >
+ ContinueOnError="false"
+ SupportCustomOutputPaths="$(IncludePackageReferencesDuringMarkupCompilation)">
+
+
<_SourceGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_ParentProjectName)$(_ParentProjectExtension).nuget.g.props"/>
<_SourceGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_ParentProjectName)$(_ParentProjectExtension).nuget.g.targets"/>
<_SourceGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_ParentProjectName)$(_ParentProjectExtension).nuget.dgspec.json"/>
+<<<<<<< HEAD
<_DestGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_TemporaryTargetAssemblyProjectName).nuget.g.props"/>
<_DestGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_TemporaryTargetAssemblyProjectName).nuget.g.targets"/>
<_DestGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_TemporaryTargetAssemblyProjectName).nuget.dgspec.json"/>
+=======
+ <_DestGeneratedNuGetPropsAndTargets Include="$(BaseIntermediateOutputPath)$(_TemporaryTargetAssemblyProjectName).nuget.g.props"/>
+ <_DestGeneratedNuGetPropsAndTargets Include="$(BaseIntermediateOutputPath)$(_TemporaryTargetAssemblyProjectName).nuget.g.targets"/>
+ <_DestGeneratedNuGetPropsAndTargets Include="$(BaseIntermediateOutputPath)$(_TemporaryTargetAssemblyProjectName).nuget.dgspec.json"/>
+>>>>>>> 860cb373 (Always copy project.assets.json and project.nuget.cache when BaseIntermediateOutputPath is set)
+
+
+ <_SourceGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)project.assets.json"/>
+ <_SourceGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)project.nuget.cache"/>
+
+ <_DestGeneratedNuGetPropsAndTargets Include="$(BaseIntermediateOutputPath)project.assets.json"/>
+ <_DestGeneratedNuGetPropsAndTargets Include="$(BaseIntermediateOutputPath)project.nuget.cache"/>
+
+
Date: Mon, 18 Jan 2021 11:23:57 -0800
Subject: [PATCH 3/3] Fix merge
---
.../src/PresentationBuildTasks/Microsoft.WinFX.targets | 6 ------
1 file changed, 6 deletions(-)
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets
index 2c999842755..4674f005c9b 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets
@@ -411,15 +411,9 @@
<_SourceGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_ParentProjectName)$(_ParentProjectExtension).nuget.g.targets"/>
<_SourceGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_ParentProjectName)$(_ParentProjectExtension).nuget.dgspec.json"/>
-<<<<<<< HEAD
- <_DestGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_TemporaryTargetAssemblyProjectName).nuget.g.props"/>
- <_DestGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_TemporaryTargetAssemblyProjectName).nuget.g.targets"/>
- <_DestGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_TemporaryTargetAssemblyProjectName).nuget.dgspec.json"/>
-=======
<_DestGeneratedNuGetPropsAndTargets Include="$(BaseIntermediateOutputPath)$(_TemporaryTargetAssemblyProjectName).nuget.g.props"/>
<_DestGeneratedNuGetPropsAndTargets Include="$(BaseIntermediateOutputPath)$(_TemporaryTargetAssemblyProjectName).nuget.g.targets"/>
<_DestGeneratedNuGetPropsAndTargets Include="$(BaseIntermediateOutputPath)$(_TemporaryTargetAssemblyProjectName).nuget.dgspec.json"/>
->>>>>>> 860cb373 (Always copy project.assets.json and project.nuget.cache when BaseIntermediateOutputPath is set)