Repository navigation
Expand file tree
/
Copy pathNetForgePackage.cs
More file actions
61 lines (56 loc) · 3.1 KB
/
Copy pathNetForgePackage.cs
File metadata and controls
61 lines (56 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Runtime.InteropServices;
using System.Threading;
using Community.VisualStudio.Toolkit;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using NetForge.VsExtension.Core;
using Task = System.Threading.Tasks.Task;
namespace NetForge.VsExtension
{
/// <summary>
/// The NetForge Visual Studio package. Registers the Tools ▸ NetForge commands and, on first load per
/// version, silently ensures the `NetForge.Templates` dotnet template is installed so NetForge appears in
/// VS's native "Create a new project" dialog. Auto-loads in the background once the shell is initialized.
/// </summary>
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[InstalledProductRegistration("NetForge", "ASP.NET Core 10 + React 19 starter", "1.0.0")]
[ProvideMenuResource("Menus.ctmenu", 1)]
[ProvideAutoLoad(VSConstants.UICONTEXT.ShellInitialized_string, PackageAutoLoadFlags.BackgroundLoad)]
[Guid("6f7a1b2c-3d4e-5f60-7182-93a4b5c6d7e8")]
public sealed class NetForgePackage : ToolkitPackage
{
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
// Nothing here may throw out of InitializeAsync — an unhandled exception makes VS report
// "package did not load correctly" and suppresses the menu. Register commands defensively.
try
{
await Commands.RegisterAsync(this);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("[NetForge] command registration failed: " + ex);
}
// Best-effort, off the UI thread: make NetForge show up in "Create a new project" without the user
// ever opening our wizard. Never blocks or fails startup.
var version = GetType().Assembly.GetName().Version?.ToString() ?? "1.0.0";
_ = System.Threading.Tasks.Task.Run(() => TemplateProvisioner.EnsureAsync(version));
}
}
/// <summary>Outbound links — kept in one place so commands and dialogs agree.</summary>
internal static class NetForgeUrls
{
public const string Configurator = "https://netforge.ebenmonney.com";
/// <summary>The configurator, deep-linked to its configure pane rather than its AI pitch —
/// what every "open the configurator" affordance should point at.</summary>
public const string Configure = "https://netforge.ebenmonney.com/#configure";
public const string Demo = "https://netforge-react.ebenmonney.com";
public const string Docs = "https://docs.netforge.ebenmonney.com";
public const string Pricing = "https://netforge.ebenmonney.com/pricing";
public const string AiBuild = "https://netforge.ebenmonney.com/ai";
public const string DotnetDownload = "https://dotnet.microsoft.com/download/dotnet/10.0";
public static void Open(string url) =>
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(url) { UseShellExecute = true });
}
}