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

Adjust properties to allow muti-target #2869

Closed
wants to merge 1 commit into from

Conversation

wli3
Copy link

@wli3 wli3 commented Apr 9, 2020

without special Sdk="Microsoft.NET.Sdk.WindowsDesktop"

The project could look like

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

</Project>

@ghost ghost requested review from vatsan-madhavan and rladuca April 9, 2020 23:54
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Apr 9, 2020
@ghost ghost requested a review from SamBent April 9, 2020 23:54
@@ -13,13 +13,11 @@ Copyright (c) .NET Foundation. All rights reserved.

<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />

Copy link
Author

@wli3 wli3 Apr 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the sdk.props and sdk.targets are empty now since props and targets are directly imported by SDK

@@ -1,40 +1,6 @@
<Project>
<PropertyGroup>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to target

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of moving the code, just add import into WinFX targets, if they are not already imported.

OR Is that pattern not preferred?

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract a new property in target to reduce the surface area, since props will always be imported

@@ -1,16 +0,0 @@
<Project>
<PropertyGroup>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to WinFx.target

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of moving the code, just add import into WinFX targets, if they are not already imported.

OR Is that pattern not preferred?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, props will be imported regardless if the workload is installed or not. So we need to move everything that could be moved.

For more see the description, linked issue. As well as the doc related to the net5.0 design.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could keep the logic in the props file and import it in the Sdk targets. No need to move the logic and risk losing history. -- Just a suggestion


<!-- PropertyGroup flags control if Itemgroups in Microsoft.NET.Sdk.WindowsDesktop.props file is being imported -->
<PropertyGroup>
<_EnableWindowsDesktopGlobbing Condition=" ('$(EnableDefaultItems)' == 'true') And ('$(UseWPF)' == 'true') And
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure the name looks good @dsplaisted

@wli3
Copy link
Author

wli3 commented Apr 10, 2020

@dsplaisted also I realized later the first insertion to SDK will fail without SDK side of change. However, I think that is fine, we can merge the SDK side of change with the insertion

Copy link
Member

@vatsan-madhavan vatsan-madhavan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Architecturally you have to understand Pbt.props/Pbt.targets before attempting this surgery. Microsoft.DotNet.Arcade.Wpf.Sdk and dotnet-wpf-test repo has dependencies in this architecture. Any change must be compatible with the test repo, or corresponding changes must be propagated there.

I highly recommend putting up PR’s involving deep refactoring that build cleanly on “build -pack”, or start with a WIP/draft PR for now until things firm-up.

A few hints:

  • In this repo, never build locally without “-pack”.
  • Release and Debug build a bit differently - exercise them both
  • Platform x86 is the default (unlike other repos where x64 is the default).
    • x86 is where the bait-and-switch packages are built.
    • AnyCpu is the same as x86 - there is no AnyCpu really, because C++/CLI is integral to the build.
  • Do not build from VS Developer command prompt - use vanilla powershell or cmd
  • Documentation/wpf.vsconfig + >= Dev16.5
  • If you set up a branch under “experimental/, you can get CI and PR builds for free. Combine it with “General Testing” channel for experiments that need those.

@wli3
Copy link
Author

wli3 commented Apr 10, 2020

@vatsan-madhavan let's setup a time to discuss that. I am surprised that .NET Core SDK is not the only public facing dependent.

@wli3 wli3 changed the title Adjust properties to allow muti-target WIP Adjust properties to allow muti-target Apr 10, 2020
@vatsan-madhavan
Copy link
Member

Microsoft.DotNet.Arcade.Wpf.Sdk is internal to WPF repos and it’s used in managing our dual-repo (or 3 repo, if you include test) build orchestration. Think of it as an augmentation to Arcade that includes all of WPF’s build intelligence and overrides, including the ability to do markup compilation from sources before WindowsDesktop SDK is built. That last part is what’s coming from Pbt.*.

This project is going to require some experimenting and getting things right. I’d recommend spending some time building the 3 repos and getting to know Microsoft.DotNet.Arcade.Wpf.Sdk, how local markup compilation works and how we build other wpf repos etc. MSBuild Binlogs are your friend.

Also spend time understanding the packaging architecture - it’s pretty powerful and unique to our repo. There is nothing magic about it, but there is a lot of convention-based stuff going on.

@vatsan-madhavan
Copy link
Member

Could you add properties to detect multiple inclusion, and simply include WindowsDesktop SDK from with the base Microsoft.NET.Sdk ?

Then if Net.Sdk.WindowsDesktop includes Microsoft.NET.Sdk, then Microsoft.NET.Sdk has to detect this condition (Net.Sdk.WindowsDesktop would have already set a property) and avoid re-inclusion.

And if Microsoft.NET.Sdk is above, and includes Net.Sdk.WindowsDesktop (owning to UseWpf or UseWindowsForms), then Net.Sdk.WindowsDesktop has to detect this condition (probably by leveraging a property set by Microsoft.NET.Sdk) and avoid re-inclusion of Microsoft.NET.Sdk

@wli3
Copy link
Author

wli3 commented Apr 16, 2020

@dsplaisted @vatsan-madhavan

Could you add properties to detect multiple inclusion, and simply include WindowsDesktop SDK from with the base Microsoft.NET.Sdk ?

Actually I don't think there is a case multiple inclusion will occur. There is graph of import

image

@wli3 wli3 requested a review from a team as a code owner April 16, 2020 05:54
@wli3
Copy link
Author

wli3 commented Apr 16, 2020

I updated my PR. This should be a "refactoring". So there should be no visible change from outside (no SDK import method change)

@rladuca
Copy link
Member

rladuca commented Apr 16, 2020

Actually I don't think there is a case multiple inclusion will occur. There is graph of import

Can someone still FrameworkReference? People have been using that idiom to get WPF/WinForms binaries in console apps. This change shouldn't break those projects.

@dsplaisted
Copy link
Member

Can someone still FrameworkReference? People have been using that idiom to get WPF/WinForms binaries in console apps. This change shouldn't break those projects.

Yes, adding an explicit FrameworkReference should not be impacted by these changes.

@wli3
Copy link
Author

wli3 commented May 19, 2020

Any update?

@wli3
Copy link
Author

wli3 commented May 30, 2020

Ping. It is been more than a month

@ryalanms
Copy link
Member

ryalanms commented Jun 9, 2020

I'll be testing this today and tomorrow. Thanks.

@ryalanms
Copy link
Member

ryalanms commented Jun 9, 2020

This will require an update to the SDK in all projects in https://github.com/microsoft/WPF-Samples.

@dsplaisted
Copy link
Member

This will require an update to the SDK in all projects in https://github.com/microsoft/WPF-Samples.

How will they need to update?

The intent is that existing projects should continue to work. It would be good to update the samples to the new project format once we ship an SDK that supports it. However I wouldn't expect the samples to break with this change. Was there a break you ran into?

@ryalanms
Copy link
Member

ryalanms commented Jun 9, 2020

Please disregard. I haven't seen anything break, and it looks like the samples are still building against 3.1.

@ryalanms
Copy link
Member

ryalanms commented Jun 9, 2020

All samples from the wpf-samples repo I've tested are building successfully against these changes. The updates to the props/targets files did not cause any regressions with building existing .NET 5 applications.

To clarify the goal and staging of this feature: @wli3 is enabling WPF applications to build with Project SDK set to Microsoft.NET.Sdk, but this will come in two separate parts. This is part 1, which refactors Microsoft.NET.Sdk.WindowsDesktop\targets files (Microsoft.WinFX.props/targets, Microsoft.NET.Sdk.WindowsDesktop.props/targets). WPF applications will require <Project = Sdk="Microsoft.NET.Sdk.WindowsDesktop"> until part 2 of @wli3's changes come in.

@wli3
Copy link
Author

wli3 commented Jun 9, 2020

@vatsan-madhavan could you dismiss your "change required"? So I can merge

@wli3 wli3 changed the title WIP Adjust properties to allow muti-target Adjust properties to allow muti-target Jun 9, 2020
@wli3
Copy link
Author

wli3 commented Jun 9, 2020

also looks like WIP bot get stuck (it was removed across the org). Maybe I need to create a new PR just to workaround that

@wli3 wli3 mentioned this pull request Jun 9, 2020
@wli3
Copy link
Author

wli3 commented Jun 9, 2020

Continue here #3111

@wli3 wli3 closed this Jun 9, 2020
@wli3 wli3 deleted the muti-target-50 branch June 10, 2020 05:56
@ghost ghost locked as resolved and limited conversation to collaborators Apr 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants