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

[release/3.1] WinFX casing and double-import fixes #4254

Closed
wants to merge 7 commits into from
Closed
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
8 changes: 4 additions & 4 deletions eng/WpfArcadeSdk/tools/Pbt.props
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
Project="../targets/Microsoft.NET.Sdk.WindowsDesktop.props"
Condition="!Exists('$(LocalMicrosoftWinFXTargets)') And '$(InternalMarkupCompilation)'=='true'"/>

We need Microsoft.WinFx.props though, so that's imported here specifically.
We need Microsoft.WinFX.props though, so that's imported here specifically.

The use of Microsoft.NET.Sdk.WindowsDesktop doesn't break the source-build promise.
- Microsoft.NET.Sdk.WindowsDesktop is built from sources
Expand All @@ -57,11 +57,11 @@
Condition="Exists('$(LocalMicrosoftWinFXProps)') "/>

<!--
Make sure WinFx.props exists when including - we sometimes include Pbt.props
Make sure WinFX.props exists when including - we sometimes include Pbt.props
from non-WPF projects (for e.g., C++ .vxproj) where this is a meaningless idea
-->
<Import Sdk="Microsoft.NET.Sdk.WindowsDesktop"
Project="../targets/Microsoft.WinFx.props"
Project="../targets/Microsoft.WinFX.props"
Condition="!Exists('$(LocalMicrosoftWinFXProps)') And
Exists('../targets/Microsoft.WinFx.props')"/>
Exists('../targets/Microsoft.WinFX.props')"/>
</Project>
4 changes: 2 additions & 2 deletions eng/WpfArcadeSdk/tools/Pbt.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<!--
This should be defined before Microsoft.WinFx.targets in imported.
This should be defined before Microsoft.WinFX.targets in imported.
It's OK if there is no DLL realized at this location - we just need to have the property define.

It is also OK for a DLL to NOT exist at the time <UsingTask> is encountered against this assembly path.
Expand Down Expand Up @@ -51,7 +51,7 @@
(a) PresentationBuildTasks.dll is built locally
(b) The TFM of the assembly matches the build toolset currently being used (netcore vs netframework)
(c) The assembly is placed at $(_PresentationBuildTasksAssembly)
(d) This is all done prior to the first ever use of a task from within this assembly by Microsoft.WinFx.targets
(d) This is all done prior to the first ever use of a task from within this assembly by Microsoft.WinFX.targets
-->
<Target Name="EnsurePbtPath"
Condition="'$(InternalMarkupCompilation)'=='true' And Exists('$(LocalMicrosoftWinFXTargets)')"
Expand Down
10 changes: 10 additions & 0 deletions packaging/Microsoft.NET.Sdk.WindowsDesktop/Sdk/Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ Copyright (c) .NET Foundation. All rights reserved.
<MicrosoftWindowsDesktopSdkPath>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\..\targets))</MicrosoftWindowsDesktopSdkPath>
</PropertyGroup>

<!--
Workaround: https://github.com/microsoft/msbuild/issues/4948
Disable .NET Framework's inbox WinFX targets when using the SDK, since, we really don't use it's build logic
and is superseded by 'WindowsDesktop' SDK that provides it's own WinFX for both NETFX and CoreCLR targets.
Make it opt-out, just in case, if something fails or we don't want to use 'WindowsDesktop' SDK's version.
-->
<PropertyGroup>
<ImportFrameworkWinFXTargets Condition="'$(ImportFrameworkWinFXTargets)' == ''">false</ImportFrameworkWinFXTargets>
</PropertyGroup>

<Import Project="$(MicrosoftWindowsDesktopSdkPath)\Microsoft.NET.Sdk.WindowsDesktop.props "/>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project>

<PropertyGroup>
<_MicrosoftNetSdkWindowsDesktop>true</_MicrosoftNetSdkWindowsDesktop>
<EnableDefaultPageItems Condition="'$(EnableDefaultPageItems)' == ''">true</EnableDefaultPageItems>
Expand All @@ -16,16 +17,13 @@

Irrespective of whether '$(TargetFrameworkIdentifier)' is '.NETCoreApp' or '.NETFramework',
the minimum value of $(_TargetFrameworkVersionValue) we will be testing for is '3.0'

-->
<_WindowsDesktopSdkTargetFrameworkVersionFloor>3.0</_WindowsDesktopSdkTargetFrameworkVersionFloor>

<!--
Represents an undefined TFV value. This will be used in comparisons of _TargetFrameworkVersionValue (defined in Microsoft.NET.WindowsDesktop.targets)
to identify when a TFV is undefined
-->
<_UndefinedTargetFrameworkVersion>0.0</_UndefinedTargetFrameworkVersion>

<!--
Initial/Default value set to 'undefined'. Updated in Microsoft.NET.WindowsDesktop.targets
-->
Expand All @@ -49,8 +47,6 @@
Condition="'$(EnableDefaultPageItems)' != 'false'" >
<Generator>MSBuild:Compile</Generator>
</Page>


<!--
See https://github.com/dotnet/wpf/issues/685
Visual Studio would prefer that we remove **/*.xaml instead of
Expand All @@ -65,7 +61,6 @@
Condition="'$(EnableDefaultApplicationDefinition)' != 'false' And '$(EnableDefaultPageItems)' != 'false'" />
</ItemGroup>


<ItemGroup Condition="('$(DisableImplicitFrameworkReferences)' != 'true') And
('$(TargetFrameworkIdentifier)' == '.NETCoreApp') And
('$(_TargetFrameworkVersionValue)' != '$(_UndefinedTargetFrameworkVersion)') And
Expand All @@ -81,15 +76,13 @@
Condition="('$(UseWPF)' != 'true') And ('$(UseWindowsForms)' == 'true')"/>
</ItemGroup>


<!--
Traditionally, Visual Studio has supplied these references for .NET Framework based
WPF Projects:

.NET 3.x: PresentationCore, PresentationFramework, WindowsBase
.NET 4.x: PresentationCore, PresentationFramework, WindowsBase, System.Xaml


Microsoft.NET.WindowsDesktop.SDK will supply the following references to .NET Framework based
WPF Projects:

Expand All @@ -101,12 +94,10 @@
.NET 4.5+: PresentationCore, PresentationFramework, WindowsBase, System.Xaml,
UIAutomationClient, UIAutomationClientSideProviders, UIAutomationProvider, UIAutomationTypes
System.Windows.Controls.Ribbon

-->
<ItemGroup Condition="('$(TargetFrameworkIdentifier)' == '.NETFramework') And
('$(_TargetFrameworkVersionValue)' != '$(_UndefinedTargetFrameworkVersion)') And
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">

<!--
The following 3 _WpfCommonNetFxReference items normally require Condition="'$(_TargetFrameworkVersionValue)' >= '3.0'", since
they are supported on .NET Framework 3.0 and above.
Expand Down Expand Up @@ -166,7 +157,6 @@
<ItemGroup Condition="('$(UseWPF)' == 'true' Or '$(UseWindowsForms)' == 'true') And
'$(_TargetFrameworkVersionValue)' != '$(_UndefinedTargetFrameworkVersion)' And
'$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)'">

<!--
Windows Forms and WPF are supported only on .NET Core 3.0+
-->
Expand Down Expand Up @@ -205,5 +195,7 @@
<SupportedTargetFramework Remove="@(_UnsupportedNETCoreAppTargetFramework);@(_UnsupportedNETStandardTargetFramework);@(_UnsupportedNETFrameworkTargetFramework)" />
</ItemGroup>

<Import Project="Microsoft.WinFX.props" />
<!-- Import WPF Build tasks only when we don't import NETFX's WinFX targets -->
<Import Project="Microsoft.WinFX.props" Condition="'$(ImportFrameworkWinFXTargets)' != 'true'" />

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
<_TargetFrameworkVersionValue>$([MSBuild]::ValueOrDefault('$(_TargetFrameworkVersionWithoutV)', '$(_UndefinedTargetFrameworkVersion)'))</_TargetFrameworkVersionValue>
</PropertyGroup>

<Import Project="Microsoft.WinFX.targets" />

<ItemGroup Condition=" ('$(EnableDefaultItems)' == 'true') And ('$(UseWPF)' == 'true') And ('$(_TargetFrameworkVersionValue)' != '$(_UndefinedTargetFrameworkVersion)') And
('$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">

Expand All @@ -34,7 +32,6 @@
-->
<Page Remove="@(Resource);@(Content)"
Condition="'$(EnableDefaultPageItems)' != 'false'" />

<!--
ApplicationDefinition must also be removed from Page. Otherwise, PresentationBuildTasks will include the
generated code for the ApplicationDefinition twice. We cannot do this in all cases in the props file as
Expand All @@ -43,7 +40,6 @@
in WPF.
-->
<Page Remove="@(ApplicationDefinition)" />

<!--
The WindowsDesktop props file removes "**/*.xaml" from None if both EnableDefaultApplicationDefinition and
EnableDefaultPageItems are true. This is done so that we remove any implicitly globbed XAML files from None
Expand Down Expand Up @@ -81,7 +77,6 @@
<Page Remove="@(Page)" />
<Page Include="@(DeduplicatedPageItems)" />
</ItemGroup>

</Target>

<!--
Expand Down Expand Up @@ -109,4 +104,8 @@
('$(_TargetFrameworkVersionValue)' != '$(_UndefinedTargetFrameworkVersion)') And ('$(_TargetFrameworkVersionValue)' &lt; '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
<NetSdkWarning ResourceName="WindowsDesktopFrameworkRequiresVersion30" />
</Target>

<!-- Import WPF Build logic only when we don't import NETFX's WinFX targets -->
<Import Project="Microsoft.WinFX.targets" Condition="'$(ImportFrameworkWinFXTargets)' != 'true'" />

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -480,14 +480,14 @@ private void Initialize(FileUnit sourceFile)
// Prime the output directory
if (TargetPath.Length > 0)
{
// check for ending '\'
if (!TargetPath.EndsWith(ESCAPED_BACKSLASH, StringComparison.Ordinal))
// check for ending Path.DirectorySeparatorChar
if (!TargetPath.EndsWith(string.Empty + Path.DirectorySeparatorChar, StringComparison.Ordinal))
{
TargetPath += ESCAPED_BACKSLASH;
TargetPath += Path.DirectorySeparatorChar;
}
}

int pathEndIndex = SourceFileInfo.RelativeSourceFilePath.LastIndexOf(ESCAPED_BACKSLASH, StringComparison.Ordinal);
int pathEndIndex = SourceFileInfo.RelativeSourceFilePath.LastIndexOf(string.Empty + Path.DirectorySeparatorChar, StringComparison.Ordinal);
string targetPath = TargetPath + SourceFileInfo.RelativeSourceFilePath.Substring(0, pathEndIndex + 1);

// Create if not already exists
Expand Down Expand Up @@ -1573,7 +1573,7 @@ private string ParentFolderPrefix
{
string relPath = TargetPath.Substring(SourceFileInfo.SourcePath.Length);
relPath += SourceFileInfo.RelativeSourceFilePath;
string[] dirs = relPath.Split(new Char[] { ESCAPED_BACKSLASH_CHAR });
string[] dirs = relPath.Split(new Char[] { Path.DirectorySeparatorChar });
for (int i = 1; i < dirs.Length; i++)
{
parentFolderPrefix += PARENTFOLDER;
Expand Down Expand Up @@ -3515,8 +3515,6 @@ internal string SubClass
private const string VER = "V";
private const string COMPONENT = "component";
private const char COMPONENT_DELIMITER = ';';
private const string ESCAPED_BACKSLASH = "\\";
private const char ESCAPED_BACKSLASH_CHAR = '\\';
private const string FORWARDSLASH = "/";
private const string URISCHEME_PACK = "pack";
private const string PARENTFOLDER = @"..\";
Expand All @@ -3534,4 +3532,3 @@ internal string SubClass
#endregion Private Data
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal class CompilerWrapper : MarshalByRefObject
internal CompilerWrapper()
{
_mc = new MarkupCompiler();
_sourceDir = Directory.GetCurrentDirectory() + "\\";
_sourceDir = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar;
_nErrors = 0;
}

Expand Down Expand Up @@ -408,7 +408,7 @@ private string GetResolvedFilePath(string filePath, ref string newSourceDir)
// and put the deepest directory that file is in as the new
// SourceDir.
//
int pathEndIndex = fullFilePath.LastIndexOf("\\", StringComparison.Ordinal);
int pathEndIndex = fullFilePath.LastIndexOf(string.Empty + Path.DirectorySeparatorChar, StringComparison.Ordinal);

newSourceDir = fullFilePath.Substring(0, pathEndIndex + 1);
newRelativeFilePath = fullFilePath.Substring(pathEndIndex + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ private void RecompileContentFiles()
{
if (ListIsNotEmpty(_mcPass1.ContentFiles))
{
string curDir = Directory.GetCurrentDirectory() + "\\";
string curDir = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar;

int count = _mcPass1.ContentFiles.Length;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ internal static string CreateFullFilePath(string thePath, string rootPath)

// get rid of '..' and '.' if any
thePath = Path.GetFullPath(thePath);

return thePath;
}

Expand All @@ -100,7 +99,7 @@ internal static string GetRootRelativePath(string path1, string path2)
string fullpath1;
string fullpath2;

string sourceDir = Directory.GetCurrentDirectory() + "\\";
string sourceDir = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar;

// make sure path1 and Path2 are both full path
// so that they can be compared on right base.
Expand Down Expand Up @@ -235,4 +234,3 @@ internal static CompilerWrapper CreateCompilerWrapper(bool fInSeparateDomain, re

#endregion TaskHelper class
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project>

<PropertyGroup>
<_PresentationBuildTasksTfm Condition="'$(MSBuildRuntimeType)' == 'Core'">netcoreapp2.1</_PresentationBuildTasksTfm>
<_PresentationBuildTasksTfm Condition="'$(MSBuildRuntimeType)' != 'Core'">net472</_PresentationBuildTasksTfm>
Expand Down
Loading