Modernize workloads and templates#462
Conversation
Use new things in the templates and workload worlds.
mattleibow
left a comment
There was a problem hiding this comment.
Some comments to point out some changes
| @@ -0,0 +1,253 @@ | |||
| #!/usr/bin/env pwsh | |||
There was a problem hiding this comment.
This script sort of works on macOS. I did not test Linux. It won't work on Windows as that requires either MSI files (I may look at this in the future) or manually copying of things.
| @@ -0,0 +1,15 @@ | |||
| { | |||
There was a problem hiding this comment.
The cli files make the dotnet new gtk --help output look nicer with the lowercase flags:
% dotnet new gtkapp --help
Gtk Application (C#)
Author: GtkSharp Contributors
Usage:
dotnet new gtkapp [options] [template options]
Options:
-n, --name <name> The name for the output being created. If no name is specified, the name of the output directory is used.
-o, --output <output> Location to place the generated output.
--dry-run Displays a summary of what would happen if the given command line were run if it would result in a template creation. [default: False]
--force Forces content to be generated even if it would change existing files. [default: False]
--no-update-check Disables checking for the template package updates when instantiating a template. [default: False]
--project <project> The project that should be used for context evaluation.
-lang, --language <C#> Specifies the template language to instantiate.
--type <project> Specifies the template type to instantiate.
Template options:
-f, --framework <net10.0|net8.0|net9.0> The target framework for the project.
Type: choice
net8.0 Target net8.0
net9.0 Target net9.0
net10.0 Target net10.0
Default: net8.0
--no-restore If specified, skips the automatic restore of the project on create.
Type: bool
Default: false
To see help for other template languages (F#, VB), use --language option:
dotnet new gtkapp -h --language F#
| } | ||
| ], | ||
| "replaces": "$(FrameworkParameter)", | ||
| "defaultValue": "net8.0" |
There was a problem hiding this comment.
I kept .NET 8 as the default.
| <PackageReference Condition="'$(UseWorkload)' != 'true'" Include="GtkSharp" Version="3.24.24.*" /> | ||
| <PackageReference Condition="'$(UseWorkload)' == 'true'" Include="GtkSharp" Version="$(GtkSharpVersion)" /> |
There was a problem hiding this comment.
The new workload in this PR will not provide the references, you will need the NuGets. But now they can be updated from a nightly or just bumped independent of the workload version.
|
see #464 |
|
second problem: |
|
but: ... |
Non-AI
Note
This PR is somewhat big and I never asked the community how they liked anything, but I was playing around for some local testing and decided to push along with some other changes. Feel free to close if this is not what you want. If any chnages are needed, let me know. If you want just parts of this, I can do smaller PRs.
I saw the workloads were using what was originally touted as the gold standard - SDK, runtime and refs in the workload. However, this is not always great as new versions will require workload things.
While working on .NET MAUI, we decided to go with a less workload-y way and just have a base x.0.100 workload installed once to add the required thigs (in the case of GtkSharp, it is the
gtktarget platform). After that, all the user needs is to update the version of the NuGet.With the GtkSharp.Sdk package, I added and split the contents across the specific files ot make future things easier:
<UsingGtkSharpSdk>propertyFor the templates, I went out on a crazy limb and made there be a single template file that is controlled by a
$(WorkloadBuild)to control the contents. Hopefully this makes edits in future nicer as there is no need to keep things in sync.I also update the project templates to support the
--frameworkand--no-restorelike the rest of .NET.AI
This pull request introduces a new PowerShell script for installing the GTK workload, refactors and enhances template configuration for workload support, and improves code style and template metadata across several files. The changes are mainly grouped into three themes: workload installation automation, template system enhancements, and code style/metadata improvements.
Workload installation automation:
Scripts/workload-install.ps1to automate the installation of the GTK workload for .NET SDKs, including manifest handling, version detection, and pack installation. This script supports custom sources and auto-detection of installation directories.Template system enhancements:
BulkReplaceTextinSource/Directory.Build.targetsto enable bulk text replacements in template files, and a build target to apply these replacements before build.Source/Templates/Directory.Build.propsand template.csprojfiles to support aWorkloadBuildparameter, allowing conditional packaging and workload-specific template variants. [1] [2]template.in.jsonand host configdotnetcli.host.jsonfor GTK application templates, supporting workload parameterization and improved symbol definitions. [1] [2]GtkNamespace.csprojto use workload-specific target frameworks and package references based on theUseWorkloadparameter. [1] [2]Code style and metadata improvements:
template.json) for dialog, widget, and window templates to use improved default names, aiding discoverability and consistency. [1] [2] [3]template.jsonfor the GTK application template in favor of the new parameterized system.