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

Fix templates for Linux builds #17205

Closed
wants to merge 1 commit into from
Closed

Conversation

moljac
Copy link
Contributor

@moljac moljac commented Sep 5, 2023

Description of Change

In project templates changed TargetFrameworks Conditions, so the Linux builds are green out of the box.

Issues Fixed

@moljac moljac requested review from a team as code owners September 5, 2023 09:13
@moljac
Copy link
Contributor Author

moljac commented Sep 5, 2023

CI error on Windows

2023-09-05T09:54:28.4117052Z C:\Users\cloudtest\.nuget\packages\gtksharp\3.24.24.34\build\GtkSharp.targets(12,5): error MSB3923: Failed to download file "https://github.com/GtkSharp/Dependencies/raw/master/gtk-3.24.24.zip".  The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing. 

@moljac
Copy link
Contributor Author

moljac commented Sep 5, 2023

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@jfversluis
Copy link
Member

See #16143

I attempted that before, we're not doing that at the time being without some other things being fixed first.

@moljac
Copy link
Contributor Author

moljac commented Sep 5, 2023

From

#15929

Seems like

dotnet workload install maui

is not supported.

But maybe

dotnet workload install maui-android

could help, for now? Shouldn't that be OK on Linux? Maybe @grendello could give us few hints.

Adding that to installation/setup would make more people happy.

Not needed already there:

https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation?tabs=visual-studio-code#linux

@grendello
Copy link

@moljac yes, dotnet workload install maui-android is the only way to get MAUI installed on Linux atm. Without fixing workloads with regards to OS/platform dependency handling, I think there's no other workaround for the moment.

@samhouts samhouts added this to the Under Consideration milestone Sep 5, 2023
@samhouts
Copy link
Member

samhouts commented Sep 5, 2023

I believe that #11738 and #5801 and #16183 are about publishing apps for Linux, not building MAUI on Linux, so these are not resolved. I removed them from the list.

@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>DOTNET_TFM-android;DOTNET_TFM-ios;DOTNET_TFM-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);DOTNET_TFM-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>DOTNET_TFM-android</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

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

Need to fix the indentation on these.

Comment on lines +4 to 6
<TargetFrameworks>DOTNET_TFM-android</TargetFrameworks>
<TargetFrameworks Condition=" ! $([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);DOTNET_TFM-ios;DOTNET_TFM-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);DOTNET_TFM-windows10.0.19041.0</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

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

I feel that this block of conditions is getting incredibly hard to understand. There's an always-on Android. There's a negative condition ios/maccat, and a positive-condition Windows.

Is there a cleaner way to slice these up?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, see #16143

We need to fix the SDK.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I'm wary of making these changes to the template to work around the correct fix to the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a cleaner way to slice these up?

Depends on definition of "cleaner".

If it means "easier to understand" then maybe:

        <TargetFrameworks Condition=" $([MSBuild]::IsOSPlatform('windows')) || $([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);DOTNET_TFM-ios;DOTNET_TFM-maccatalyst</TargetFrameworks>

I went for less-cycles concept driven by "green", "sustainable", "shorter inner loop" (for large numbers especially).

Note "windows" as 1st in most cases 2nd condition should not be evaluated (only for mac).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, see #16143

Matthew. I really did not see that PR, but it seems similar, moreover the same if whitespace is ignored.

<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);DOTNET_TFM-ios;DOTNET_TFM-maccatalyst</TargetFrameworks>

<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);DOTNET_TFM-ios;DOTNET_TFM-maccatalyst</TargetFrameworks>

@Eilon Eilon added the area-templates Project templates, Item Templates for Blazor and MAUI label Sep 5, 2023
@mattleibow
Copy link
Member

Duplicate of #16143

@mattleibow mattleibow marked this as a duplicate of #16143 Sep 5, 2023
@Eilon
Copy link
Member

Eilon commented Sep 5, 2023

Duplicate of #16143

Should we close this PR then for now?

@mattleibow
Copy link
Member

@samhouts ?

@Redth
Copy link
Member

Redth commented Sep 5, 2023

I'm not sure if this is the right change we should be making here.

We had a PR like this previously which we closed: #16143 (comment)

The most correct way to solve this would be to add the very most basic support of getting C# / managed code for -iOS and -maccatalyst TFM's compiling on linux by creating the appropriate workload packs/aliases for them. I don't believe this is a huge effort, android does this already, and we need to do this anyway to make the workload install experience easier on linux.

Adding these types of conditions to our templates makes them more complicated, and requires manual intervention to undo these types of conditions if in the future we were to properly fix what this change tries to work around.

@Redth Redth added the do-not-merge Don't merge this PR label Sep 5, 2023
@Eilon
Copy link
Member

Eilon commented Sep 5, 2023

I agree with @Redth . I think this template change is a workaround for a real fix that should go into the lower-level SDKs. If anyone needs this behavior right now they can follow the guidance in this PR in their own projects, but it's probably not something we want every new .NET 8 project to have.

@samhouts
Copy link
Member

samhouts commented Sep 6, 2023

@moljac I agree with the statements from Eilon and redth. This an excellent resource for developers that need to be unblocked, so I very much appreciate you tracking this down! For now, we'll close this, and we'll see if @dalexsoto has thoughts on how we can build this into the iOS/MacCat packages for NET 9.

@samhouts samhouts closed this Sep 6, 2023
@moljac
Copy link
Contributor Author

moljac commented Sep 6, 2023

@Eilon

I agree with @Redth . I think this template change is a workaround for a real fix that should go into the lower-level SDKs.

I agree completely, but shouldn't that logic lead to:

<TargetFrameworks>DOTNET_TFM-android;DOTNET_TFM-ios;DOTNET_TFM-maccatalyst;DOTNET_TFM-windows10.0.19041.0;DOTNET_TFM-tizen</TargetFrameworks>

???

Note: single line TFMs and no conditions for all development (not targeted) platforms.
OK. Remove tizen, not owned by the team. It was added for the sake of the argument.

I saw linux issue, dug for few more (forgot to search for related PRs) and thought "Oh this is easy", because I am working creating my templates for repro samples.

It was supposed to be quick (and temporary) fix for something community asks for. Nothing more.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 6, 2023
@samhouts samhouts removed this from the Under Consideration milestone Jul 1, 2024
@moljac moljac deleted the dev/moljac/fix-template-for-linux branch October 17, 2024 10:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-templates Project templates, Item Templates for Blazor and MAUI do-not-merge Don't merge this PR
Projects
None yet
7 participants