Microsoft-ui-xaml: Proposal: new SDK style in WinUI csproj?

Created on 5 Oct 2020  ·  12Comments  ·  Source: microsoft/microsoft-ui-xaml

Proposal: New SDK style in

Please ensure there is new SDK style format support in WinUI projects

Summary

The new SDK style was introduced some years ago. UWP hasn't yet made it there and still uses the old SDK format.
Please enable using the new SDK in the generated project templates. Maybe with the aid of MSBuildSdkExtras.

Rationale

  • New SDK format is much easier to handle
  • It supports multi-targeting
  • Nicer and cleaner syntax

Scope

| Capability | Priority |
| :---------- | :------- |
| Enable UWP app project to be in new SDK style and ability to run it as startup project | Must |
| Support multi-targeting WinUI class libraries containing XAML to serve as a WinUI project dependency
- while supporting XAML preview and Hot Reload | Should |
| Deafult all WinUI templates to use the SDK style | Should |

Important notes

I believe this feature will require cooperation between this team and the project-system team.

Related

area-Tooling feature proposal needs-triage needs-winui-3 team-Markup

Most helpful comment

@stevenbrix I really need this as well. I'm currently using the SDK Extras and it's a pretty horrible experience. My library sits across UWP, Android, and .NET Core. You can see the csproj here.

The biggest issue I face is that I have to exclude UWP specific files conditionally by project. That means UWP files don't show up in search results and there are a bunch of other issues.

Please make this easier for us.

All 12 comments

I think that winui 3 RTM will support this, @MikeHillberg or @Austin-Lamb or @stevenbrix can you confirm?

Support multi-targeting WinUI class libraries containing XAML to serve as a WinUI project dependency

@weitzhandler can you elaborate more on what you mean by this?

For instance, I am able to create a project that contains UWP XAML files, which is a multi-targeting project, and I'm able to link to it from an UWP project properly, while the XAML files can hot-reload and preview properly.

@stevenbrix I really need this as well. I'm currently using the SDK Extras and it's a pretty horrible experience. My library sits across UWP, Android, and .NET Core. You can see the csproj here.

The biggest issue I face is that I have to exclude UWP specific files conditionally by project. That means UWP files don't show up in search results and there are a bunch of other issues.

Please make this easier for us.

I'm currently using the SDK Extras and it's a pretty horrible experience

@MelbourneDeveloper what is so terrible about the experience?

If we were to multi-target using Microsoft.NET.Sdk, what could we do differently?

The current thinking is that there won't be a uap TFM anymore, and we'll just use net5.0-windows tfms for uap as well. Would that make it simpler for either of you to accomplish your goals, or more difficult?

what could we do differently?

Proper XAML support (preview, hot-reload), in those libraries, ability to have the main library run as startup project while being SDK (currently not possible). My take at this.

@stevenbrix have you tried it?

It's nothing particular to UWP. This is a problem for all platforms that don't support the SDK format automatically. This is how I'm forced to edit my project currently. I literally cannot search through UWP code, and I have to do a rebuild on the library every time. There may be a better way, but nobody has articulated it to me. That's only the start of it.

image

We've all heard about how .NET 5 is going to fix things for us, but the reality is that this is a long way off. Even when that happens, it's not as though UWP is going to disappear from the face of the earth. UWP will still exist, and .NET 5 won't help. We still need to be able to build libraries for UWP unless there's something I've missed...

I don't know if this is the right place to requesting this, but someone needs to take the MS Build Extras SDK format, roll it out for all platforms (Android, iOS, UWP) and fix the issues so that we can easily target multiple platforms with SDK style projects. The old csproj formats are simply not acceptable. Currently, we're in limbo. We use the old csproj format with all of its flaws, or we use MS Build Extras.

what could we do differently?

I don't know what team is responsible for this - I suspect it will be the visual studio team, but what we need is SDK style projects, fully implemented, by default, across all platforms.

@stevenbrix I just got a message from someone who cloned my library. He doesn't have the Visual Studio UWP tools installed. So, the library does not compile. Also, the library does not compile on macOS Visual Studio. So, the only option I know about is to manually the csproj file and remove targets that are not installed.

Again, I don't think this is your responsibility. This is a Visual Studio issue. Visual Studio should recognise that the platforms are not installed and give the user the ability to build the ones that they have.

image

.NET 5 isn't going to magically fix all this. <- prove me wrong

As I said in my original post, this will definitely require some collaboration between teams, but WinUI without proper SDK-Style support is a major bummer.
I opened this issue.

I would assume that the SDK-style format support comes with the .NET 5 support.

image

@stevenbrix If that's the case, we could update the entries in the roadmap for .NET 5 with this prefix " (includes SDK-style project format)"

Adding @JeanRoca for FYI

I don't know if this is the right place to requesting this, but someone needs to take the MS Build Extras SDK format, roll it out for all platforms (Android, iOS, UWP) and fix the issues so that we can easily target multiple platforms with SDK style projects. The old csproj formats are simply not acceptable. Currently, we're in limbo. We use the old csproj format with all of its flaws, or we use MS Build Extras.

@MelbourneDeveloper, this sounds like something that will be coming in .NET6 once there is iOS and Android support built-in to Microsoft.NET.SDK, but @terrajobst and @clairernovotny can speak to that better than I can

As I said in my original post, this will definitely require some collaboration between teams, but WinUI without proper SDK-Style support is a major bummer.

@weitzhandler, what do you classify as "proper SDK-style support"? Our Desktop projects are SDK-style, or are you referring to the fact that we don't have UWP project files that are the same?

@stevenbrix just to confirm...

I guess what we're touching on here is a huge topic. I've tried to follow the conversation, but I'm still not clear on many things. The community would benefit from a write-up about this.

Please correct any of my misunderstandings here. My naive understanding is that .NET 5 and .NET 6 are in alpha/preview stage. The plan is to roll .NET 5/6 out to Android, and iOS eventually. WinUI 3 (The UWP XAML/graphics engine) will also be rolled in to .NET 5/6 (Windows only). When all this happens, we will be able to build SDK style projects for .NET 5/6. Those libraries will run on the .NET 5/6 CLR. Any device that runs that CLR will run those libraries.

Meantime, we've still got Xamarin.Forms, and UWP that are not going to support .NET 5 / 6. My understanding is that these won't ever support .NET 5 /6. Currently, if we want to build a library for these platforms, the choices are the old csproj format, or the MS Build Extras format. Both have their flaws. So, my question is: are there any plans to improve the multi-targeting experience for non-.NET platforms (Xamarin / UWP) or do we have to wait until those platforms support .NET 5/6?

Was this page helpful?
0 / 5 - 0 ratings