feat: GtkSharp net6 workload (#351)

* feat: GtkSharp net6 workload

* feat(Workload): GtkSharp template packs

* chore: Support .NET SDK 6.0.300

And also changed the build script to target SDK bands.

* build: Workload install and uninstall targets
This commit is contained in:
Trung Nguyen 2022-05-29 15:55:50 +07:00 committed by GitHub
parent c2e4f61033
commit 60376ae510
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 1974 additions and 4 deletions

View file

@ -0,0 +1,211 @@
#addin "nuget:?package=Microsoft.Win32.Registry&version=5.0.0"
using System;
using D = System.IO.Directory;
using F = System.IO.File;
using P = System.IO.Path;
using Pr = System.Diagnostics.Process;
using PSI = System.Diagnostics.ProcessStartInfo;
using R = Microsoft.Win32.Registry;
using RI = System.Runtime.InteropServices.RuntimeInformation;
using Z = System.IO.Compression.ZipFile;
class TargetEnvironment
{
public static string DotNetInstallPath { get; private set; }
public static string DotNetInstalledWorkloadsMetadataPath { get; private set; }
public static string DotNetInstallerTypeMetadataPath { get; private set; }
public static string DotNetManifestPath { get; private set; }
public static string DotNetPacksPath { get; private set; }
public static string DotNetTemplatePacksPath { get; private set; }
public static string DotNetCliPath { get; private set; }
public static string DotNetCliFeatureBand { get; private set; }
static TargetEnvironment()
{
DotNetInstallPath = Environment.GetEnvironmentVariable("DOTNET_ROOT");
if (DotNetInstallPath == null)
{
if (OperatingSystem.IsWindows())
{
DotNetInstallPath = P.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "dotnet");
}
else if (OperatingSystem.IsLinux())
{
DotNetInstallPath = "/usr/share/dotnet";
}
else if (OperatingSystem.IsMacOS())
{
DotNetInstallPath = "/usr/local/share/dotnet";
}
}
DotNetCliPath = P.Combine(DotNetInstallPath, "dotnet");
var proc = Pr.Start(new PSI()
{
FileName = DotNetCliPath,
Arguments = "--version",
RedirectStandardOutput = true,
});
proc.WaitForExit();
DotNetCliFeatureBand = proc.StandardOutput.ReadToEnd().Trim();
DotNetCliFeatureBand = DotNetCliFeatureBand.Substring(0, DotNetCliFeatureBand.Length - 2) + "00";
DotNetInstalledWorkloadsMetadataPath = P.Combine(DotNetInstallPath, "metadata", "workloads", DotNetCliFeatureBand, "InstalledWorkloads");
DotNetInstallerTypeMetadataPath = P.Combine(DotNetInstallPath, "metadata", "workloads", DotNetCliFeatureBand, "InstallerType");
DotNetManifestPath = P.Combine(DotNetInstallPath, "sdk-manifests", DotNetCliFeatureBand);
DotNetPacksPath = P.Combine(DotNetInstallPath, "packs");
DotNetTemplatePacksPath = P.Combine(DotNetInstallPath, "template-packs");
}
public static void RegisterInstalledWorkload(string workloadName)
{
D.CreateDirectory(DotNetInstalledWorkloadsMetadataPath);
F.WriteAllText(P.Combine(DotNetInstalledWorkloadsMetadataPath, workloadName), string.Empty);
if (F.Exists(P.Combine(DotNetInstallerTypeMetadataPath, "msi")))
{
//HKLM:\SOFTWARE\Microsoft\dotnet\InstalledWorkloads\Standalone\x64\6.0.300\gtk
// TODO: Check for other Windows architectures (x86 and arm64)
var archString = RI.OSArchitecture.ToString().ToLower();
var hklm = R.LocalMachine;
var software = hklm.CreateSubKey("SOFTWARE");
var microsoft = software.CreateSubKey("Microsoft");
var dotnet = microsoft.CreateSubKey("dotnet");
var installedWorkloads = dotnet.CreateSubKey("InstalledWorkloads");
var standalone = installedWorkloads.CreateSubKey("Standalone");
var arch = standalone.CreateSubKey(archString);
var version = arch.CreateSubKey(DotNetCliFeatureBand);
var workload = version.CreateSubKey(workloadName);
workload.Close();
version.Close();
arch.Close();
standalone.Close();
installedWorkloads.Close();
dotnet.Close();
microsoft.Close();
software.Close();
hklm.Close();
}
}
public static void UnregisterInstalledWorkload(string workloadName)
{
F.Delete(P.Combine(DotNetInstalledWorkloadsMetadataPath, workloadName));
if (F.Exists(P.Combine(DotNetInstallerTypeMetadataPath, "msi")))
{
var archString = RI.OSArchitecture.ToString().ToLower();
var hklm = R.LocalMachine;
var software = hklm.CreateSubKey("SOFTWARE");
var microsoft = software.CreateSubKey("Microsoft");
var dotnet = microsoft.CreateSubKey("dotnet");
var installedWorkloads = dotnet.CreateSubKey("InstalledWorkloads");
var standalone = installedWorkloads.CreateSubKey("Standalone");
var arch = standalone.CreateSubKey(archString);
var version = arch.CreateSubKey(DotNetCliFeatureBand);
version.DeleteSubKey(workloadName, false);
version.Close();
arch.Close();
standalone.Close();
installedWorkloads.Close();
dotnet.Close();
microsoft.Close();
software.Close();
hklm.Close();
}
}
public static void InstallManifests(string manifestName, string manifestPackPath)
{
var targetDirectory = P.Combine(DotNetManifestPath, manifestName);
var tempDirectory = P.Combine(targetDirectory, "temp");
// Delete existing installations to avoid conflict.
if (D.Exists(targetDirectory))
{
D.Delete(targetDirectory, true);
}
// Also creates the target
D.CreateDirectory(tempDirectory);
Z.ExtractToDirectory(manifestPackPath, tempDirectory);
var tempDataDirectory = P.Combine(tempDirectory, "data");
foreach (var filePath in D.GetFiles(tempDataDirectory))
{
var targetFilePath = P.Combine(targetDirectory, P.GetFileName(filePath));
F.Copy(filePath, targetFilePath, true);
}
D.Delete(tempDirectory, true);
}
public static void UninstallManifests(string manifestName)
{
var targetDirectory = P.Combine(DotNetManifestPath, manifestName);
if (D.Exists(targetDirectory))
{
D.Delete(targetDirectory, true);
}
}
public static void InstallPack(string name, string version, string packPath)
{
var targetDirectory = P.Combine(DotNetPacksPath, name, version);
if (D.Exists(targetDirectory))
{
D.Delete(targetDirectory, true);
}
D.CreateDirectory(targetDirectory);
Z.ExtractToDirectory(packPath, targetDirectory);
}
public static void UninstallPack(string name, string version)
{
var packInstallDirectory = P.Combine(DotNetPacksPath, name);
var targetDirectory = P.Combine(packInstallDirectory, version);
if (D.Exists(targetDirectory))
{
D.Delete(targetDirectory, true);
}
// Clean up the template if no other verions exist.
try
{
D.Delete(packInstallDirectory, false);
}
catch (System.IO.IOException)
{
// Silently fail. Mostly because the directory is not empty (there are other verions installed).
}
}
public static void InstallTemplatePack(string packName, string packPath)
{
D.CreateDirectory(DotNetTemplatePacksPath);
var targetPath = P.Combine(DotNetTemplatePacksPath, packName);
F.Copy(packPath, targetPath, true);
}
public static void UninstallTemplatePack(string packName)
{
var targetPath = P.Combine(DotNetTemplatePacksPath, packName);
if (F.Exists(targetPath))
{
F.Delete(targetPath);
}
}
}

View file

@ -0,0 +1,12 @@
<Project>
<PropertyGroup>
<_GtkSharpNetVersion>6.0</_GtkSharpNetVersion>
<_GtkSharpSourceDirectory>$(MSBuildThisFileDirectory)</_GtkSharpSourceDirectory>
<_GtkSharpBuildOutputDirectory>$(MSBuildThisFileDirectory)..\BuildOutput\</_GtkSharpBuildOutputDirectory>
</PropertyGroup>
<PropertyGroup>
<PackageProjectUrl>https://github.com/GtkSharp/GtkSharp</PackageProjectUrl>
<RepositoryUrl>https://github.com/GtkSharp/GtkSharp</RepositoryUrl>
</PropertyGroup>
</Project>

View file

@ -1,9 +1,15 @@
<Project> <Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)..\'))" />
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks> <TargetFrameworks>net$(_GtkSharpNetVersion);netstandard2.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PackageProjectUrl>https://github.com/GtkSharp/GtkSharp</PackageProjectUrl> <OutputPath>$(_GtkSharpBuildOutputDirectory)\$(Configuration)</OutputPath>
<RepositoryUrl>https://github.com/GtkSharp/GtkSharp</RepositoryUrl> <!--
<OutputPath>..\..\..\BuildOutput\$(Configuration)</OutputPath> Microsoft.DotNet.SharedFramework.Sdk requires our framework assemblies to be signed
(to have a "public key token")
-->
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\GtkSharp.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

BIN
Source/Libs/GtkSharp.snk Normal file

Binary file not shown.

View file

@ -0,0 +1,22 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)..\'))" />
<PropertyGroup>
<_GtkSharpVersion>$([System.Text.RegularExpressions.Regex]::Match($(Version), '(\d+)\.(\d+)'))</_GtkSharpVersion>
<_GtkSharpTfm>net$(_GtkSharpNetVersion)-gtk</_GtkSharpTfm>
<_GtkSharpFullTfm>net$(_GtkSharpNetVersion)-gtk$(_GtkSharpVersion)</_GtkSharpFullTfm>
<_GtkSharpManifestVersionBand Condition=" '$(_GtkSharpManifestVersionBand)' == '' ">6.0.300</_GtkSharpManifestVersionBand>
<!-- Folder format somewhat similar to packs in .NET, making stuff easier to install -->
<OutputPath>$(_GtkSharpBuildOutputDirectory)WorkloadPacks\$(Configuration)\$(MSBuildProjectName)\$(Version)</OutputPath>
</PropertyGroup>
<ItemGroup>
<None Include="$(_GtkSharpSourceDirectory)Libs\GtkSharp\Icon.png" Pack="true" PackagePath="\" />
</ItemGroup>
<PropertyGroup>
<PackageIcon>Icon.png</PackageIcon>
<Authors>GtkSharp Contributors</Authors>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,60 @@
<Project Sdk="Microsoft.Build.NoTargets">
<Import Project="..\Shared\Common.targets" />
<PropertyGroup>
<PackageId>$(PackageId).Manifest-$(_GtkSharpManifestVersionBand)</PackageId>
<Description>GtkSharp workload manifest</Description>
</PropertyGroup>
<PropertyGroup>
<!-- Workaround: Visual Studio complains if the version contains 4 parts (major.minor.patch.rev, the one that GtkSharp is currently using) -->
<_GtkSharpVersionMajorMinorPatch>$([System.Text.RegularExpressions.Regex]::Match($(Version), '(\d+)\.(\d+).(\d+)'))</_GtkSharpVersionMajorMinorPatch>
<_GtkSharpManifestVersion>$(Version.Replace('$(_GtkSharpVersionMajorMinorPatch).', '$(_GtkSharpVersionMajorMinorPatch)-rev.'))</_GtkSharpManifestVersion>
</PropertyGroup>
<Import Project="..\Shared\ReplaceText.targets" />
<ItemGroup>
<None Update="WorkloadManifest.targets" CopyToOutputDirectory="PreserveNewest" Pack="true" PackagePath="data" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../GtkSharp.*/*.csproj" />
<!-- Exclude self -->
<ProjectReference Remove="../GtkSharp.NET.*/*.csproj" />
</ItemGroup>
<Target Name="_ReplaceJsonText"
BeforeTargets="Build;AssignTargetPaths"
Inputs="$(MSBuildProjectFile);WorkloadManifest.in.json"
Outputs="$(IntermediateOutputPath)WorkloadManifest.json">
<ReplaceText
Input="WorkloadManifest.in.json"
Output="$(IntermediateOutputPath)WorkloadManifest.json"
OldValue="@VERSION@"
NewValue="$(Version)"
/>
<ReplaceText
Input="$(IntermediateOutputPath)WorkloadManifest.json"
Output="$(IntermediateOutputPath)WorkloadManifest.json"
OldValue="@GTKSHARPMANIFESTVERSION@"
NewValue="$(_GtkSharpManifestVersion)"
/>
<ItemGroup>
<None
Include="$(IntermediateOutputPath)WorkloadManifest.json"
Link="WorkloadManifest.json"
CopyToOutputDirectory="PreserveNewest"
Pack="true"
PackagePath="data"
/>
<FileWrites Include="$(IntermediateOutputPath)WorkloadManifest.json" />
</ItemGroup>
</Target>
</Project>

View file

@ -0,0 +1,39 @@
{
"version": "@GTKSHARPMANIFESTVERSION@",
"workloads": {
"gtk": {
"description": ".NET SDK workload for building GtkSharp applications.",
"packs": [
"GtkSharp.Sdk",
"GtkSharp.Ref",
"GtkSharp.Runtime"
]
}
},
"packs": {
"GtkSharp.Sdk": {
"kind": "sdk",
"version": "@VERSION@"
},
"GtkSharp.Ref": {
"kind": "framework",
"version": "@VERSION@"
},
"GtkSharp.Runtime": {
"kind": "framework",
"version": "@VERSION@"
},
"GtkSharp.Workload.Template.CSharp": {
"kind": "template",
"version": "@VERSION@"
},
"GtkSharp.Workload.Template.FSharp": {
"kind": "template",
"version": "@VERSION@"
},
"GtkSharp.Workload.Template.VBNet": {
"kind": "template",
"version": "@VERSION@"
}
}
}

View file

@ -0,0 +1,7 @@
<Project>
<Import Project="Sdk.targets" Sdk="GtkSharp.Sdk" Condition="'$(TargetPlatformIdentifier)' == 'gtk'" />
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0')) ">
<SdkSupportedTargetPlatformIdentifier Include="gtk" DisplayName="GTK" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.Build.NoTargets">
<Import Project="..\Shared\Common.targets" />
<Import Project="..\Shared\Frameworks.targets" />
<PropertyGroup>
<Description>GtkSharp targeting pack</Description>
</PropertyGroup>
<ItemGroup>
<None Include="$(_GtkSharpBuildOutputDirectory)$(Configuration)\net$(_GtkSharpNetVersion)\*.dll" />
<None Update="@(None)" CopyToOutputDirectory="PreserveNewest" Visible="false" Link="ref\$(_GtkSharpFullTfm)\%(FileName)%(Extension)" />
<_PackageFiles Include="@(None)" PackagePath="ref\$(_GtkSharpFullTfm)" TargetPath="ref\$(_GtkSharpFullTfm)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(_GtkSharpSourceDirectory)Libs\**\*.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.Build.NoTargets">
<Import Project="..\Shared\Common.targets" />
<Import Project="..\Shared\Frameworks.targets" />
<PropertyGroup>
<Description>GtkSharp runtime pack</Description>
</PropertyGroup>
<ItemGroup>
<None Include="$(_GtkSharpBuildOutputDirectory)$(Configuration)\net$(_GtkSharpNetVersion)\*.dll" />
<None Update="@(None)" CopyToOutputDirectory="PreserveNewest" Visible="false" Link="lib\$(_GtkSharpFullTfm)\%(FileName)%(Extension)" />
<_PackageFiles Include="@(None)" PackagePath="lib\$(_GtkSharpFullTfm)" TargetPath="lib\$(_GtkSharpFullTfm)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(_GtkSharpSourceDirectory)Libs\**\*.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,58 @@
<Project Sdk="Microsoft.Build.NoTargets">
<Import Project="..\Shared\Common.targets" />
<PropertyGroup>
<Description>GtkSharp SDK. Enabled via the net6.0-gtk TFM.</Description>
</PropertyGroup>
<ItemGroup>
<None Remove="**\*.in.*" />
<None Update="@(None)" PackagePath="" CopyToOutputDirectory="PreserveNewest" Pack="true" />
<None
Include="$(_GtkSharpSourceDirectory)Libs\GtkSharp\GtkSharp.targets"
Link="targets\GtkSharp.targets"
CopyToOutputDirectory="PreserveNewest"
Pack="true"
PackagePath="targets"
Visible="false"
/>
</ItemGroup>
<Import Project="..\Shared\ReplaceText.targets" />
<Target Name="_ReplaceSdkText"
BeforeTargets="Build;AssignTargetPaths"
Inputs="$(MSBuildProjectFile);Sdk\Sdk.in.targets"
Outputs="$(IntermediateOutputPath)Sdk.targets">
<ReplaceText
Input="Sdk\Sdk.in.targets"
Output="$(IntermediateOutputPath)Sdk.targets"
OldValue="@GTKSHARPVERSION@"
NewValue="$(_GtkSharpVersion)"
/>
<ReplaceText
Input="$(IntermediateOutputPath)Sdk.targets"
Output="$(IntermediateOutputPath)Sdk.targets"
OldValue="@GTKSHARPNETVERSION@"
NewValue="$(_GtkSharpNetVersion)"
/>
<ItemGroup>
<None
Include="$(IntermediateOutputPath)Sdk.targets"
Link="Sdk\Sdk.targets"
CopyToOutputDirectory="PreserveNewest"
Pack="true"
PackagePath="Sdk"
Visible="false"
/>
<FileWrites Include="$(IntermediateOutputPath)Sdk.targets" />
</ItemGroup>
</Target>
</Project>

View file

@ -0,0 +1,66 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- GtkSharp target from the original nuget package -->
<Import Project="..\targets\GtkSharp.targets" />
<!-- Register net6.0-gtk3.24 TFM -->
<ItemGroup>
<SupportedPlatform Include="gtk" />
</ItemGroup>
<PropertyGroup>
<_DefaultTargetPlatformVersion>@GTKSHARPVERSION@</_DefaultTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup>
<TargetPlatformSupported>true</TargetPlatformSupported>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">$(_DefaultTargetPlatformVersion)</TargetPlatformVersion>
</PropertyGroup>
<ItemGroup>
<SdkSupportedTargetPlatformVersion Include="@GTKSHARPVERSION@" />
</ItemGroup>
<!-- Register GtkSharp runtime -->
<ItemGroup>
<KnownFrameworkReference
Include="GtkSharp"
TargetFramework="net@GTKSHARPNETVERSION@"
RuntimeFrameworkName="GtkSharp"
DefaultRuntimeFrameworkVersion="**FromWorkload**"
LatestRuntimeFrameworkVersion="**FromWorkload**"
TargetingPackName="GtkSharp.Ref"
TargetingPackVersion="**FromWorkload**"
RuntimePackNamePatterns="GtkSharp.Runtime"
RuntimePackRuntimeIdentifiers="win-x64;win-x86;linux-x64;linux-x86;osx-x64"
Profile="GTK"
/>
</ItemGroup>
<!-- Reference GtkSharp runtime -->
<ItemGroup Condition=" '$(DisableImplicitFrameworkReferences)' != 'true' ">
<FrameworkReference
Include="GtkSharp"
IsImplicitlyDefined="true"
Pack="false"
PrivateAssets="All"
/>
</ItemGroup>
<!-- Project properties -->
<PropertyGroup>
<_IsGtkDefined>$([System.Text.RegularExpressions.Regex]::IsMatch('$(DefineConstants.Trim())', '(^|;)GTK($|;)'))</_IsGtkDefined>
<DefineConstants Condition="!$(_IsGtkDefined)">GTK;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<!-- Must be self-contained. Framework-dependent builds cannot see our custom runtime -->
<SelfContained>true</SelfContained>
<RuntimeIdentifier Condition=" '$(RuntimeIdentifier)' == '' and $([MSBuild]::IsOsPlatform('Windows')) and '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64' ">win-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition=" '$(RuntimeIdentifier)' == '' and $([MSBuild]::IsOsPlatform('Windows')) and '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X86' ">win-x86</RuntimeIdentifier>
<RuntimeIdentifier Condition=" '$(RuntimeIdentifier)' == '' and $([MSBuild]::IsOsPlatform('Linux')) and '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64' ">linux-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition=" '$(RuntimeIdentifier)' == '' and $([MSBuild]::IsOsPlatform('Linux')) and '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X86' ">linux-x86</RuntimeIdentifier>
<RuntimeIdentifier Condition=" '$(RuntimeIdentifier)' == '' and $([MSBuild]::IsOsPlatform('OSX')) and '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64' ">osx-x64</RuntimeIdentifier>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,47 @@
<Project Sdk="Microsoft.Build.NoTargets">
<Import Project="..\Shared\Templates.targets" />
<PropertyGroup>
<Title>GTK templates for CSharp</Title>
<Description>A set of C# templates for your .NET GTK Application. Installed with the GtkSharp .NET workload.</Description>
</PropertyGroup>
<ItemGroup>
<_GtkSharpTemplateContent Include="content\**" />
<_GtkSharpTemplateContent Remove="**\*.in.*" />
<None Include="@(_GtkSharpTemplateContent)"
CopyToOutputDirectory="PreserveNewest"
Pack="true"
PackagePath="content"
/>
</ItemGroup>
<Import Project="..\Shared\ReplaceText.targets" />
<Target Name="_ReplaceJsonText"
BeforeTargets="Build;AssignTargetPaths"
Inputs="$(MSBuildProjectFile);content\GtkSharp.Application.CSharp\.template.config\template.in.json"
Outputs="$(IntermediateOutputPath)template.json">
<ReplaceText
Input="content\GtkSharp.Application.CSharp\.template.config\template.in.json"
Output="$(IntermediateOutputPath)template.json"
OldValue="@GTKSHARPNETVERSION@"
NewValue="$(_GtkSharpNetVersion)"
/>
<ItemGroup>
<None
Include="$(IntermediateOutputPath)template.json"
Link="content\GtkSharp.Application.CSharp\.template.config\template.json"
CopyToOutputDirectory="PreserveNewest"
Pack="true"
PackagePath="content\GtkSharp.Application.CSharp\.template.config\template.json"
/>
<FileWrites Include="$(IntermediateOutputPath)template.json" />
</ItemGroup>
</Target>
</Project>

View file

@ -0,0 +1,29 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"GUI App"
],
"name": "Gtk Application",
"identity": "GtkSharp.Application.CSharp",
"groupIdentity": "GtkSharp.Application",
"shortName": "gtk",
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "GtkNamespace",
"preferNameDirectory": true,
"symbols": {
"targetframework": {
"type": "parameter",
"description": "The target framework for the project.",
"defaultValue": "net@GTKSHARPNETVERSION@-gtk",
"replaces": "$(FrameworkParameter)"
}
},
"primaryOutputs": [
{ "path": "GtkNamespace.csproj" }
]
}

View file

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>$(FrameworkParameter)</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="**\*.glade" />
<EmbeddedResource Include="**\*.glade">
<LogicalName>%(Filename)%(Extension)</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Project>

View file

@ -0,0 +1,35 @@
using System;
using Gtk;
using UI = Gtk.Builder.ObjectAttribute;
namespace GtkNamespace
{
class MainWindow : Window
{
[UI] private Label _label1 = null;
[UI] private Button _button1 = null;
private int _counter;
public MainWindow() : this(new Builder("MainWindow.glade")) { }
private MainWindow(Builder builder) : base(builder.GetRawOwnedObject("MainWindow"))
{
builder.Autoconnect(this);
DeleteEvent += Window_DeleteEvent;
_button1.Clicked += Button1_Clicked;
}
private void Window_DeleteEvent(object sender, DeleteEventArgs a)
{
Application.Quit();
}
private void Button1_Clicked(object sender, EventArgs a)
{
_counter++;
_label1.Text = "Hello World! This button has been clicked " + _counter + " time(s).";
}
}
}

View file

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkWindow" id="MainWindow">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Example Window</property>
<property name="default_width">480</property>
<property name="default_height">240</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">4</property>
<property name="margin_right">4</property>
<property name="margin_top">4</property>
<property name="margin_bottom">4</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="_label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Hello World!</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="_button1">
<property name="label" translatable="yes">Click me!</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View file

@ -0,0 +1,23 @@
using System;
using Gtk;
namespace GtkNamespace
{
class Program
{
[STAThread]
public static void Main(string[] args)
{
Application.Init();
var app = new Application("org.GtkNamespace.GtkNamespace", GLib.ApplicationFlags.None);
app.Register(GLib.Cancellable.Current);
var win = new MainWindow();
app.AddWindow(win);
win.Show();
Application.Run();
}
}
}

View file

@ -0,0 +1,33 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"UI"
],
"name": "Gtk Dialog",
"identity": "GtkSharp.Dialog.CSharp",
"groupIdentity": "GtkSharp.Dialog",
"shortName": "gtkdialog",
"tags": {
"language": "C#",
"type": "item"
},
"sourceName": "Gtk_Dialog",
"primaryOutputs": [
{
"path": "Gtk_Dialog.cs"
},
{
"path": "Gtk_Dialog.glade"
}
],
"defaultName": "Gtk_Dialog",
"symbols": {
"namespace": {
"description": "Namespace for the generated files",
"replaces": "GtkNamespace",
"type": "parameter"
}
}
}

View file

@ -0,0 +1,24 @@
using System;
using Gtk;
using UI = Gtk.Builder.ObjectAttribute;
namespace GtkNamespace
{
class Gtk_Dialog : Dialog
{
public Gtk_Dialog() : this(new Builder("Gtk_Dialog.glade")) { }
private Gtk_Dialog(Builder builder) : base(builder.GetRawOwnedObject("Gtk_Dialog"))
{
builder.Autoconnect(this);
DefaultResponse = ResponseType.Cancel;
Response += Dialog_Response;
}
private void Dialog_Response(object o, ResponseArgs args)
{
Hide();
}
}
}

View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="Gtk_Dialog">
<property name="can_focus">False</property>
<property name="default_width">320</property>
<property name="default_height">260</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="button1">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-7">button1</action-widget>
</action-widgets>
</object>
</interface>

View file

@ -0,0 +1,33 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"UI"
],
"name": "Gtk Widget",
"identity": "GtkSharp.Widget.CSharp",
"groupIdentity": "GtkSharp.Widget",
"shortName": "gtkwidget",
"tags": {
"language": "C#",
"type": "item"
},
"sourceName": "Gtk_Widget",
"primaryOutputs": [
{
"path": "Gtk_Widget.cs"
},
{
"path": "Gtk_Widget.glade"
}
],
"defaultName": "Gtk_Widget",
"symbols": {
"namespace": {
"description": "Namespace for the generated files",
"replaces": "GtkNamespace",
"type": "parameter"
}
}
}

View file

@ -0,0 +1,16 @@
using System;
using Gtk;
using UI = Gtk.Builder.ObjectAttribute;
namespace GtkNamespace
{
public class Gtk_Widget : Box
{
public Gtk_Widget() : this(new Builder("Gtk_Widget.glade")) { }
private Gtk_Widget(Builder builder) : base(builder.GetRawOwnedObject("Gtk_Widget"))
{
builder.Autoconnect(this);
}
}
}

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkBox" id="${EscapedIdentifier}">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
</interface>

View file

@ -0,0 +1,33 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"UI"
],
"name": "Gtk Window",
"identity": "GtkSharp.Window.CSharp",
"groupIdentity": "GtkSharp.Window",
"shortName": "gtkwindow",
"tags": {
"language": "C#",
"type": "item"
},
"sourceName": "Gtk_Window",
"primaryOutputs": [
{
"path": "Gtk_Window.cs"
},
{
"path": "Gtk_Window.glade"
}
],
"defaultName": "Gtk_Window",
"symbols": {
"namespace": {
"description": "Namespace for the generated files",
"replaces": "GtkNamespace",
"type": "parameter"
}
}
}

View file

@ -0,0 +1,16 @@
using System;
using Gtk;
using UI = Gtk.Builder.ObjectAttribute;
namespace GtkNamespace
{
class Gtk_Window : Window
{
public Gtk_Window() : this(new Builder("Gtk_Window.glade")) { }
private Gtk_Window(Builder builder) : base(builder.GetRawOwnedObject("Gtk_Window"))
{
builder.Autoconnect(this);
}
}
}

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkWindow" id="Gtk_Window">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Gtk_Window</property>
<child>
<placeholder/>
</child>
</object>
</interface>

View file

@ -0,0 +1,47 @@
<Project Sdk="Microsoft.Build.NoTargets">
<Import Project="..\Shared\Templates.targets" />
<PropertyGroup>
<Title>GTK templates for FSharp</Title>
<Description>A set of F# templates for your .NET GTK Application. Installed with the GtkSharp .NET workload.</Description>
</PropertyGroup>
<ItemGroup>
<_GtkSharpTemplateContent Include="content\**" />
<_GtkSharpTemplateContent Remove="**\*.in.*" />
<None Include="@(_GtkSharpTemplateContent)"
CopyToOutputDirectory="PreserveNewest"
Pack="true"
PackagePath="content"
/>
</ItemGroup>
<Import Project="..\Shared\ReplaceText.targets" />
<Target Name="_ReplaceJsonText"
BeforeTargets="Build;AssignTargetPaths"
Inputs="$(MSBuildProjectFile);content\GtkSharp.Application.FSharp\.template.config\template.in.json"
Outputs="$(IntermediateOutputPath)template.json">
<ReplaceText
Input="content\GtkSharp.Application.FSharp\.template.config\template.in.json"
Output="$(IntermediateOutputPath)template.json"
OldValue="@GTKSHARPNETVERSION@"
NewValue="$(_GtkSharpNetVersion)"
/>
<ItemGroup>
<None
Include="$(IntermediateOutputPath)template.json"
Link="content\GtkSharp.Application.FSharp\.template.config\template.json"
CopyToOutputDirectory="PreserveNewest"
Pack="true"
PackagePath="content\GtkSharp.Application.FSharp\.template.config\template.json"
/>
<FileWrites Include="$(IntermediateOutputPath)template.json" />
</ItemGroup>
</Target>
</Project>

View file

@ -0,0 +1,29 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"GUI App"
],
"name": "Gtk Application",
"identity": "GtkSharp.Application.FSharp",
"groupIdentity": "GtkSharp.Application",
"shortName": "gtk",
"tags": {
"language": "F#",
"type": "project"
},
"sourceName": "GtkNamespace",
"preferNameDirectory": true,
"symbols": {
"targetframework": {
"type": "parameter",
"description": "The target framework for the project.",
"defaultValue": "net@GTKSHARPNETVERSION@-gtk",
"replaces": "$(FrameworkParameter)"
}
},
"primaryOutputs": [
{ "path": "GtkNamespace.fsproj" }
]
}

View file

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>$(FrameworkParameter)</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="MainWindow.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<None Remove="**\*.glade" />
<EmbeddedResource Include="**\*.glade">
<LogicalName>%(Filename)%(Extension)</LogicalName>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.24.24.*" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,24 @@
namespace GtkNamespace
open Gtk
type MainWindow (builder : Builder) as this =
inherit Window(builder.GetRawOwnedObject("MainWindow"))
let mutable _label1 : Label = null
let mutable _button1 : Button = null
let mutable _counter = 0;
do
_label1 <- builder.GetObject("_label1") :?> Label
_button1 <- builder.GetObject("_button1") :?> Button
this.DeleteEvent.Add(fun _ ->
Application.Quit()
)
_button1.Clicked.Add(fun _ ->
_counter <- _counter + 1
_label1.Text <- "Hello World! This button has been clicked " + _counter.ToString() + " time(s)."
)
new() = new MainWindow(new Builder("MainWindow.glade"))

View file

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkWindow" id="MainWindow">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Example Window</property>
<property name="default_width">480</property>
<property name="default_height">240</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">4</property>
<property name="margin_right">4</property>
<property name="margin_top">4</property>
<property name="margin_bottom">4</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="_label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Hello World!</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="_button1">
<property name="label" translatable="yes">Click me!</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View file

@ -0,0 +1,18 @@
namespace GtkNamespace
module Program =
open Gtk
[<EntryPoint>]
let main argv =
Application.Init()
let app = new Application("org.GtkNamespace.GtkNamespace", GLib.ApplicationFlags.None)
app.Register(GLib.Cancellable.Current) |> ignore;
let win = new MainWindow()
app.AddWindow(win)
win.Show()
Application.Run()
0

View file

@ -0,0 +1,33 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"UI"
],
"name": "Gtk Dialog",
"identity": "GtkSharp.Dialog.FSharp",
"groupIdentity": "GtkSharp.Dialog",
"shortName": "gtkdialog",
"tags": {
"language": "F#",
"type": "item"
},
"sourceName": "Gtk_Dialog",
"primaryOutputs": [
{
"path": "Gtk_Dialog.fs"
},
{
"path": "Gtk_Dialog.glade"
}
],
"defaultName": "Gtk_Dialog",
"symbols": {
"namespace": {
"description": "Namespace for the generated files",
"replaces": "GtkNamespace",
"type": "parameter"
}
}
}

View file

@ -0,0 +1,13 @@
namespace GtkNamespace
open Gtk
type Gtk_Dialog (builder : Builder) as this =
inherit Dialog(builder.GetRawOwnedObject("Gtk_Dialog"))
do
this.DefaultResponse <- ResponseType.Cancel;
this.Response.Add(fun _ ->
this.Hide();
)
new() = new Gtk_Dialog(new Builder("Gtk_Dialog.glade"))

View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="Gtk_Dialog">
<property name="can_focus">False</property>
<property name="default_width">320</property>
<property name="default_height">260</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="button1">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-7">button1</action-widget>
</action-widgets>
</object>
</interface>

View file

@ -0,0 +1,33 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"UI"
],
"name": "Gtk Widget",
"identity": "GtkSharp.Widget.FSharp",
"groupIdentity": "GtkSharp.Widget",
"shortName": "gtkwidget",
"tags": {
"language": "F#",
"type": "item"
},
"sourceName": "Gtk_Widget",
"primaryOutputs": [
{
"path": "Gtk_Widget.fs"
},
{
"path": "Gtk_Widget.glade"
}
],
"defaultName": "Gtk_Widget",
"symbols": {
"namespace": {
"description": "Namespace for the generated files",
"replaces": "GtkNamespace",
"type": "parameter"
}
}
}

View file

@ -0,0 +1,8 @@
namespace GtkNamespace
open Gtk
type Gtk_Widget (builder : Builder) =
inherit Box(builder.GetRawOwnedObject("Gtk_Widget"))
new() = new Gtk_Widget(new Builder("Gtk_Widget.glade"))

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkBox" id="${EscapedIdentifier}">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
</interface>

View file

@ -0,0 +1,33 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"UI"
],
"name": "Gtk Window",
"identity": "GtkSharp.Window.FSharp",
"groupIdentity": "GtkSharp.Window",
"shortName": "gtkwindow",
"tags": {
"language": "F#",
"type": "item"
},
"sourceName": "Gtk_Window",
"primaryOutputs": [
{
"path": "Gtk_Window.fs"
},
{
"path": "Gtk_Window.glade"
}
],
"defaultName": "Gtk_Window",
"symbols": {
"namespace": {
"description": "Namespace for the generated files",
"replaces": "GtkNamespace",
"type": "parameter"
}
}
}

View file

@ -0,0 +1,8 @@
namespace GtkNamespace
open Gtk
type Gtk_Window (builder : Builder) =
inherit Window(builder.GetRawOwnedObject("Gtk_Window"))
new() = new Gtk_Window(new Builder("Gtk_Window.glade"))

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkWindow" id="Gtk_Window">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Gtk_Window</property>
<child>
<placeholder/>
</child>
</object>
</interface>

View file

@ -0,0 +1,47 @@
<Project Sdk="Microsoft.Build.NoTargets">
<Import Project="..\Shared\Templates.targets" />
<PropertyGroup>
<Title>GTK templates for Visual Basic</Title>
<Description>A set of Visual Basic templates for your .NET GTK Application. Installed with the GtkSharp .NET workload.</Description>
</PropertyGroup>
<ItemGroup>
<_GtkSharpTemplateContent Include="content\**" />
<_GtkSharpTemplateContent Remove="**\*.in.*" />
<None Include="@(_GtkSharpTemplateContent)"
CopyToOutputDirectory="PreserveNewest"
Pack="true"
PackagePath="content"
/>
</ItemGroup>
<Import Project="..\Shared\ReplaceText.targets" />
<Target Name="_ReplaceJsonText"
BeforeTargets="Build;AssignTargetPaths"
Inputs="$(MSBuildProjectFile);content\GtkSharp.Application.VBNet\.template.config\template.in.json"
Outputs="$(IntermediateOutputPath)template.json">
<ReplaceText
Input="content\GtkSharp.Application.VBNet\.template.config\template.in.json"
Output="$(IntermediateOutputPath)template.json"
OldValue="@GTKSHARPNETVERSION@"
NewValue="$(_GtkSharpNetVersion)"
/>
<ItemGroup>
<None
Include="$(IntermediateOutputPath)template.json"
Link="content\GtkSharp.Application.VBNet\.template.config\template.json"
CopyToOutputDirectory="PreserveNewest"
Pack="true"
PackagePath="content\GtkSharp.Application.VBNet\.template.config\template.json"
/>
<FileWrites Include="$(IntermediateOutputPath)template.json" />
</ItemGroup>
</Target>
</Project>

View file

@ -0,0 +1,29 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"GUI App"
],
"name": "Gtk Application",
"identity": "GtkSharp.Application.VBNet",
"groupIdentity": "GtkSharp.Application",
"shortName": "gtk",
"tags": {
"language": "VB",
"type": "project"
},
"sourceName": "GtkNamespace",
"preferNameDirectory": true,
"symbols": {
"targetframework": {
"type": "parameter",
"description": "The target framework for the project.",
"defaultValue": "net@GTKSHARPNETVERSION@-gtk",
"replaces": "$(FrameworkParameter)"
}
},
"primaryOutputs": [
{ "path": "GtkNamespace.vbproj" }
]
}

View file

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>$(FrameworkParameter)</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="**\*.glade" />
<EmbeddedResource Include="**\*.glade">
<LogicalName>%(Filename)%(Extension)</LogicalName>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.24.24.*" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkWindow" id="MainWindow">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Example Window</property>
<property name="default_width">480</property>
<property name="default_height">240</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">4</property>
<property name="margin_right">4</property>
<property name="margin_top">4</property>
<property name="margin_bottom">4</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="_label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Hello World!</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="_button1">
<property name="label" translatable="yes">Click me!</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View file

@ -0,0 +1,37 @@
Imports System
Imports Gtk
Imports UI = Gtk.Builder.ObjectAttribute
Namespace GtkNamespace
Public Class MainWindow
Inherits Window
Private _counter = 0
<UI>Private _label1 As Label
<UI>Private _button1 As Button
Public Sub New (builder as Builder)
MyBase.New(builder.GetRawOwnedObject("MainWindow"))
builder.Autoconnect (Me)
AddHandler MyBase.DeleteEvent, AddressOf Window_Delete
AddHandler _button1.Clicked, AddressOf Button1_Clicked
End Sub
Public Sub New ()
Me.New(new Builder("MainWindow.glade"))
End Sub
Private Sub Window_Delete (ByVal sender As Object, ByVal a As DeleteEventArgs)
Application.Quit ()
a.RetVal = true
End Sub
Private Sub Button1_Clicked (ByVal sender As Object, ByVal a As EventArgs)
_counter += 1
_label1.Text = "Hello World! This button has been clicked " + _counter.ToString() + " time(s)."
End Sub
End Class
End Namespace

View file

@ -0,0 +1,21 @@
Imports System
Imports Gtk
Namespace GtkNamespace
Public Class MainClass
Public Shared Sub Main ()
Application.Init ()
Dim app as new Application ("org.GtkNamespace.GtkNamespace", GLib.ApplicationFlags.None)
app.Register (GLib.Cancellable.Current)
Dim win as new MainWindow ()
app.AddWindow (win)
win.Show ()
Application.Run ()
End Sub
End Class
End Namespace

View file

@ -0,0 +1,33 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"UI"
],
"name": "Gtk Dialog",
"identity": "GtkSharp.Dialog.VBNet",
"groupIdentity": "GtkSharp.Dialog",
"shortName": "gtkdialog",
"tags": {
"language": "VB",
"type": "item"
},
"sourceName": "Gtk_Dialog",
"primaryOutputs": [
{
"path": "Gtk_Dialog.vb"
},
{
"path": "Gtk_Dialog.glade"
}
],
"defaultName": "Gtk_Dialog",
"symbols": {
"namespace": {
"description": "Namespace for the generated files",
"replaces": "GtkNamespace",
"type": "parameter"
}
}
}

View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="Gtk_Dialog">
<property name="can_focus">False</property>
<property name="default_width">320</property>
<property name="default_height">260</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="button1">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-7">button1</action-widget>
</action-widgets>
</object>
</interface>

View file

@ -0,0 +1,27 @@
Imports System
Imports Gtk
Imports UI = Gtk.Builder.ObjectAttribute
Namespace GtkNamespace
Public Class Gtk_Dialog
Inherits Dialog
Public Sub New (builder as Builder)
MyBase.New (builder.GetRawOwnedObject("Gtk_Dialog"))
builder.Autoconnect (Me)
DefaultResponse = ResponseType.Cancel
AddHandler MyBase.Response, AddressOf Dialog_OnResponse
End Sub
Public Sub New ()
Me.New (new Builder ("Gtk_Dialog.glade"))
End Sub
Private Sub Dialog_OnResponse (ByVal sender As Object, ByVal args As ResponseArgs)
Hide ()
End Sub
End Class
End Namespace

View file

@ -0,0 +1,33 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"UI"
],
"name": "Gtk Widget",
"identity": "GtkSharp.Widget.VBNet",
"groupIdentity": "GtkSharp.Widget",
"shortName": "gtkwidget",
"tags": {
"language": "VB",
"type": "item"
},
"sourceName": "Gtk_Widget",
"primaryOutputs": [
{
"path": "Gtk_Widget.vb"
},
{
"path": "Gtk_Widget.glade"
}
],
"defaultName": "Gtk_Widget",
"symbols": {
"namespace": {
"description": "Namespace for the generated files",
"replaces": "GtkNamespace",
"type": "parameter"
}
}
}

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkBox" id="${EscapedIdentifier}">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
</interface>

View file

@ -0,0 +1,20 @@
Imports System
Imports Gtk
Imports UI = Gtk.Builder.ObjectAttribute
Namespace GtkNamespace
Public Class Gtk_Widget
Inherits Box
Public Sub New (builder as Builder)
MyBase.New (builder.GetRawOwnedObject("Gtk_Widget"))
builder.Autoconnect (Me)
End Sub
Public Sub New ()
Me.New (new Builder("Gtk_Widget.glade"))
End Sub
End Class
End Namespace

View file

@ -0,0 +1,33 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"UI"
],
"name": "Gtk Window",
"identity": "GtkSharp.Window.VBNet",
"groupIdentity": "GtkSharp.Window",
"shortName": "gtkwindow",
"tags": {
"language": "VB",
"type": "item"
},
"sourceName": "Gtk_Window",
"primaryOutputs": [
{
"path": "Gtk_Window.vb"
},
{
"path": "Gtk_Window.glade"
}
],
"defaultName": "Gtk_Window",
"symbols": {
"namespace": {
"description": "Namespace for the generated files",
"replaces": "GtkNamespace",
"type": "parameter"
}
}
}

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkWindow" id="Gtk_Window">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Gtk_Window</property>
<child>
<placeholder/>
</child>
</object>
</interface>

View file

@ -0,0 +1,20 @@
Imports System
Imports Gtk
Imports UI = Gtk.Builder.ObjectAttribute
Namespace GtkNamespace
Public Class Gtk_Window
Inherits Window
Public Sub New (builder as Builder)
MyBase.New (builder.GetRawOwnedObject("Gtk_Window"))
builder.Autoconnect (Me)
End Sub
Public Sub New ()
Me.New (new Builder ("Gtk_Window.glade"))
End Sub
End Class
End Namespace

View file

@ -0,0 +1,12 @@
<Project>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageType>DotnetPlatform</PackageType>
<PackageId>$(MSBuildProjectName)</PackageId>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<GenerateDependencyFile>false</GenerateDependencyFile>
<IncludeSymbols>false</IncludeSymbols>
<NoWarn>$(NoWarn);NU5100;NU5128;NU5130;NU5131</NoWarn>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,42 @@
<Project>
<ItemGroup>
<_FrameworkListFile Condition=" !$(MSBuildProjectName.Contains('.Runtime')) " Include="$(IntermediateOutputPath)FrameworkList.xml" />
<_FrameworkListFile Condition=" !$(MSBuildProjectName.Contains('.Ref')) " Include="$(IntermediateOutputPath)RuntimeList.xml" />
</ItemGroup>
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.SharedFramework.Sdk" Version="7.0.0-beta.22259.5" />
<UsingTask TaskName="CreateFrameworkListFile" AssemblyFile="$(DotNetSharedFrameworkTaskFile)"/>
<PropertyGroup>
<!-- Microsoft.DotNet.SharedFramework.Sdk changes this property, creating a symbols package with no meaning. -->
<IncludeSymbols>false</IncludeSymbols>
</PropertyGroup>
<!-- https://github.com/dotnet/runtime/blob/0647ec314948904319da5eb15e9931f7c85ed1e2/src/installer/pkg/projects/Directory.Build.targets#L281 -->
<Target Name="_GenerateFrameworkListFile"
BeforeTargets="Build;AssignTargetPaths">
<ItemGroup>
<_RootAttribute Include="Name" Value="GtkSharp" />
<_RootAttribute Include="TargetFrameworkIdentifier" Value=".NETCoreApp" />
<_RootAttribute Include="TargetFrameworkVersion" Value="6.0" />
<_RootAttribute Include="FrameworkName" Value="$(MSBuildProjectName.Replace('.Ref','').Replace('.Runtime',''))" />
<_AssemblyFiles Include="@(_PackageFiles)" Condition=" '%(_PackageFiles.Extension)' == '.dll' and '%(_PackageFiles.SubFolder)' == '' " />
<_Classifications Include="@(_AssemblyFiles->'%(FileName)%(Extension)'->Distinct())" Profile="GTK" />
</ItemGroup>
<!-- https://github.com/dotnet/arcade/blob/1924d7ea148c9f26ca3d82b60f0a775a5389ed22/src/Microsoft.DotNet.Build.Tasks.SharedFramework.Sdk/src/CreateFrameworkListFile.cs -->
<CreateFrameworkListFile
Files="@(_AssemblyFiles)"
FileClassifications="@(_Classifications)"
TargetFile="%(_FrameworkListFile.Identity)"
TargetFilePrefixes="ref;lib"
RootAttributes="@(_RootAttribute)"
/>
<ItemGroup>
<FileWrites Include="@(_FrameworkListFile)" />
<Content Include="@(_FrameworkListFile)" CopyToOutputDirectory="PreserveNewest" Pack="true" PackagePath="data" Link="data\%(FileName)%(Extension)" />
</ItemGroup>
</Target>
</Project>

View file

@ -0,0 +1,20 @@
<Project>
<UsingTask TaskName="ReplaceText"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Input ParameterType="System.String" Required="true" />
<Output ParameterType="System.String" Required="true" />
<OldValue ParameterType="System.String" Required="true" />
<NewValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.IO" />
<Code Type="Fragment" Language="cs">
<![CDATA[
File.WriteAllText(Output, File.ReadAllText(Input).Replace(OldValue, NewValue));
]]>
</Code>
</Task>
</UsingTask>
</Project>

View file

@ -0,0 +1,14 @@
<Project>
<PropertyGroup>
<PackageType>Template</PackageType>
<PackageId>$(MSBuildProjectName)</PackageId>
<TargetFramework>netstandard2.0</TargetFramework>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<GenerateDependencyFile>false</GenerateDependencyFile>
<IncludeSymbols>false</IncludeSymbols>
<NoWarn>NU5128</NoWarn>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,5 @@
{
"msbuild-sdks": {
"Microsoft.Build.NoTargets": "3.3.0"
}
}

View file

@ -0,0 +1,7 @@
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>

View file

@ -1,5 +1,6 @@
#load CakeScripts\GAssembly.cake #load CakeScripts\GAssembly.cake
#load CakeScripts\Settings.cake #load CakeScripts\Settings.cake
#load CakeScripts\TargetEnvironment.cake
#addin "Cake.FileHelpers&version=5.0.0" #addin "Cake.FileHelpers&version=5.0.0"
#addin "Cake.Incubator&version=7.0.0" #addin "Cake.Incubator&version=7.0.0"
@ -13,6 +14,7 @@ var configuration = Argument("Configuration", "Release");
var msbuildsettings = new DotNetMSBuildSettings(); var msbuildsettings = new DotNetMSBuildSettings();
var list = new List<GAssembly>(); var list = new List<GAssembly>();
var supportedVersionBands = new List<string>() {"6.0.100", "6.0.200", "6.0.300"};
// TASKS // TASKS
@ -128,6 +130,33 @@ Task("PackageNuGet")
DotNetPack(gassembly.Csproj, settings); DotNetPack(gassembly.Csproj, settings);
}); });
Task("PackageWorkload")
.IsDependentOn("Build")
.Does(() =>
{
var packSettings = new DotNetPackSettings
{
MSBuildSettings = msbuildsettings,
Configuration = configuration,
OutputDirectory = "BuildOutput/NugetPackages",
// Some of the nugets here depend on output generated during build.
NoBuild = false
};
DotNetPack("Source/Workload/GtkSharp.Workload.Template.CSharp/GtkSharp.Workload.Template.CSharp.csproj", packSettings);
DotNetPack("Source/Workload/GtkSharp.Workload.Template.FSharp/GtkSharp.Workload.Template.FSharp.csproj", packSettings);
DotNetPack("Source/Workload/GtkSharp.Workload.Template.VBNet/GtkSharp.Workload.Template.VBNet.csproj", packSettings);
DotNetPack("Source/Workload/GtkSharp.Ref/GtkSharp.Ref.csproj", packSettings);
DotNetPack("Source/Workload/GtkSharp.Runtime/GtkSharp.Runtime.csproj", packSettings);
DotNetPack("Source/Workload/GtkSharp.Sdk/GtkSharp.Sdk.csproj", packSettings);
foreach (var band in supportedVersionBands)
{
packSettings.MSBuildSettings = packSettings.MSBuildSettings.WithProperty("_GtkSharpManifestVersionBand", band);
DotNetPack("Source/Workload/GtkSharp.NET.Sdk.Gtk/GtkSharp.NET.Sdk.Gtk.csproj", packSettings);
}
});
Task("PackageTemplates") Task("PackageTemplates")
.IsDependentOn("Init") .IsDependentOn("Init")
.Does(() => .Does(() =>
@ -144,11 +173,81 @@ Task("PackageTemplates")
DotNetPack("Source/Templates/GtkSharp.Template.VBNet/GtkSharp.Template.VBNet.csproj", settings); DotNetPack("Source/Templates/GtkSharp.Template.VBNet/GtkSharp.Template.VBNet.csproj", settings);
}); });
const string manifestName = "GtkSharp.NET.Sdk.Gtk";
var manifestPack = $"{manifestName}.Manifest-{TargetEnvironment.DotNetCliFeatureBand}.{Settings.Version}.nupkg";
var manifestPackPath = $"BuildOutput/NugetPackages/{manifestPack}";
var packNames = new List<string>()
{
"GtkSharp.Ref",
"GtkSharp.Runtime",
"GtkSharp.Sdk"
};
var templateLanguages = new List<string>()
{
"CSharp",
"FSharp",
"VBNet"
};
Task("InstallWorkload")
.IsDependentOn("PackageWorkload")
.IsDependentOn("PackageTemplates")
.Does(() =>
{
Console.WriteLine($"Installing workload for SDK version {TargetEnvironment.DotNetCliFeatureBand}, at {TargetEnvironment.DotNetInstallPath}");
Console.WriteLine($"Installing manifests to {TargetEnvironment.DotNetManifestPath}");
TargetEnvironment.InstallManifests(manifestName, manifestPackPath);
Console.WriteLine($"Installing packs to {TargetEnvironment.DotNetPacksPath}");
foreach (var name in packNames)
{
Console.WriteLine($"Installing {name}");
var pack = $"{name}.{Settings.Version}.nupkg";
var packPath = $"BuildOutput/NugetPackages/{pack}";
TargetEnvironment.InstallPack(name, Settings.Version, packPath);
}
Console.WriteLine($"Installing templates to {TargetEnvironment.DotNetTemplatePacksPath}");
foreach (var language in templateLanguages)
{
Console.WriteLine($"Installing {language} templates");
var pack = $"GtkSharp.Workload.Template.{language}.{Settings.Version}.nupkg";
var packPath = $"BuildOutput/NugetPackages/{pack}";
TargetEnvironment.InstallTemplatePack(pack, packPath);
}
Console.WriteLine($"Registering \"gtk\" installed workload...");
TargetEnvironment.RegisterInstalledWorkload("gtk");
});
Task("UninstallWorkload")
.Does(() =>
{
Console.WriteLine($"Uninstalling workload for SDK version {TargetEnvironment.DotNetCliFeatureBand}, at {TargetEnvironment.DotNetInstallPath}");
Console.WriteLine($"Removing manifests from {TargetEnvironment.DotNetManifestPath}");
TargetEnvironment.UninstallManifests(manifestName);
Console.WriteLine($"Removing packs from {TargetEnvironment.DotNetPacksPath}");
foreach (var name in packNames)
{
Console.WriteLine($"Removing {name}");
TargetEnvironment.UninstallPack(name, Settings.Version);
}
Console.WriteLine($"Removing templates from {TargetEnvironment.DotNetTemplatePacksPath}");
foreach (var language in templateLanguages)
{
Console.WriteLine($"Removing {language} templates");
var pack = $"GtkSharp.Workload.Template.{language}.{Settings.Version}.nupkg";
TargetEnvironment.UninstallTemplatePack(pack);
}
Console.WriteLine($"Unregistering \"gtk\" installed workload...");
TargetEnvironment.UnregisterInstalledWorkload("gtk");
});
// TASK TARGETS // TASK TARGETS
Task("Default") Task("Default")
.IsDependentOn("Build") .IsDependentOn("Build")
.IsDependentOn("PackageNuGet") .IsDependentOn("PackageNuGet")
.IsDependentOn("PackageWorkload")
.IsDependentOn("PackageTemplates"); .IsDependentOn("PackageTemplates");
// EXECUTION // EXECUTION