diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b61ea766dfe..2d1ad7cf2d2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -149,6 +149,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + MARKETPLACE_PAT: ${{ secrets.MARKETPLACE_PAT }} - name: Make a Release if: github.ref_type == 'tag' @@ -158,7 +159,7 @@ jobs: tag: ${{ github.ref_name }} allowUpdates: true removeArtifacts: true - artifacts: "nugets/*.nupkg" + artifacts: "nugets/*.nupkg;vsix/MonoGame.Templates.VSExtension.vsix" token: ${{ secrets.GITHUB_TOKEN }} tests: diff --git a/Templates/MonoGame.Templates.VSExtension/MonoGame.Templates.VSExtension.csproj b/Templates/MonoGame.Templates.VSExtension/MonoGame.Templates.VSExtension.csproj index 3a8b07ed888..ac8ca42e99d 100644 --- a/Templates/MonoGame.Templates.VSExtension/MonoGame.Templates.VSExtension.csproj +++ b/Templates/MonoGame.Templates.VSExtension/MonoGame.Templates.VSExtension.csproj @@ -1,22 +1,10 @@ - - + + - 17.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - Debug - AnyCPU - 2.0 - {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - {9EBC26EB-8412-4723-B715-1F5BCCECD77A} + net472 Library - Properties MonoGame.Templates.VSExtension MonoGame.Templates.VSExtension - v4.7.2 - win true true true @@ -27,28 +15,8 @@ Program $(DevEnvDir)devenv.exe /rootsuffix Exp - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true ..\..\Artifacts\MonoGame.Templates.VSExtension\ - TRACE - prompt - 4 - - - - Designer @@ -58,16 +26,21 @@ - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + true - - + + <_TemplatePackage Include="..\..\Artifacts\NuGet\MonoGame.Templates.CSharp.*.nupkg" /> diff --git a/Templates/MonoGame.Templates.VSExtension/MonoGame.Templates.VSExtension.sln b/Templates/MonoGame.Templates.VSExtension/MonoGame.Templates.VSExtension.sln new file mode 100644 index 00000000000..43d72d2c7b1 --- /dev/null +++ b/Templates/MonoGame.Templates.VSExtension/MonoGame.Templates.VSExtension.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35327.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoGame.Templates.VSExtension", "MonoGame.Templates.VSExtension.csproj", "{78561F26-117A-4D42-B177-84374B768B45}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {78561F26-117A-4D42-B177-84374B768B45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {78561F26-117A-4D42-B177-84374B768B45}.Debug|Any CPU.Build.0 = Debug|Any CPU + {78561F26-117A-4D42-B177-84374B768B45}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {78561F26-117A-4D42-B177-84374B768B45}.Release|Any CPU.ActiveCfg = Release|Any CPU + {78561F26-117A-4D42-B177-84374B768B45}.Release|Any CPU.Build.0 = Release|Any CPU + {78561F26-117A-4D42-B177-84374B768B45}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BFA7EE0A-52F0-44FA-9D7E-CC05D906A0CF} + EndGlobalSection +EndGlobal diff --git a/Templates/MonoGame.Templates.VSExtension/Properties/AssemblyInfo.cs b/Templates/MonoGame.Templates.VSExtension/Properties/AssemblyInfo.cs deleted file mode 100644 index 7c07c0b27a8..00000000000 --- a/Templates/MonoGame.Templates.VSExtension/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MonoGame.Templates.VSExtension")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MonoGame.Templates.VSExtension")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Templates/MonoGame.Templates.VSExtension/source.extension.vsixmanifest b/Templates/MonoGame.Templates.VSExtension/source.extension.vsixmanifest index 94827dc3424..e20bec4111c 100644 --- a/Templates/MonoGame.Templates.VSExtension/source.extension.vsixmanifest +++ b/Templates/MonoGame.Templates.VSExtension/source.extension.vsixmanifest @@ -1,24 +1,43 @@ - - - MonoGame Framework C# project templates - This extension contains the C# project templates for using the MonoGame Framework - .NET,C#,Game development,Templates,Games,Gamedev,Project,Mono,MonoGame - - - - amd64 - - - - - - - - - - - - + + + MonoGame Framework C# project templates + This extension contains the C# project templates for using the MonoGame Framework + .NET,C#,Game development,Templates,Games,Gamedev,Project,Mono,MonoGame + + + + amd64 + + + amd64 + + + amd64 + + + arm64 + + + arm64 + + + arm64 + + + + + + + + + + + + + + + + diff --git a/build/BuildContext.cs b/build/BuildContext.cs index b2887c31f5c..057086ff76c 100644 --- a/build/BuildContext.cs +++ b/build/BuildContext.cs @@ -17,7 +17,7 @@ public enum ProjectType public class BuildContext : FrostingContext { - public static string VersionBase = "1.0.0"; + public static string VersionBase = "3.8.2"; public static readonly Regex VersionRegex = new(@"^v\d+.\d+.\d+", RegexOptions.Compiled | RegexOptions.IgnoreCase); public static readonly string DefaultRepositoryUrl = "https://github.com/MonoGame/MonoGame"; diff --git a/build/DeployTasks/DeployVsixToMarketplaceTask.cs b/build/DeployTasks/DeployVsixToMarketplaceTask.cs new file mode 100644 index 00000000000..50be0062dcc --- /dev/null +++ b/build/DeployTasks/DeployVsixToMarketplaceTask.cs @@ -0,0 +1,57 @@ + +using System.Net.Http.Headers; +using System.Text; + +namespace BuildScripts; + +[TaskName("DeployVsixToMarketplaceTask")] +[IsDependentOn(typeof(DownloadArtifactsTask))] +public sealed class DeployVsixToMarketplaceTask : FrostingTask +{ + public override bool ShouldRun(BuildContext context) + { + if (context.BuildSystem().IsRunningOnGitHubActions) + { + var workflow = context.BuildSystem().GitHubActions.Environment.Workflow; + if (workflow.RefType == GitHubActionsRefType.Tag && + !string.IsNullOrWhiteSpace(context.EnvironmentVariable("MARKETPLACE_PAT"))) + { + return true; + } + } + + return false; + } + + public override async void Run(BuildContext context) + { + var pat = context.EnvironmentVariable("MARKETPLACE_PAT"); + var publisher = "MonoGame"; + var extensionName = "MonoGame.Templates.VSExtension"; + + var filePath = "vsix/MonoGame.Templates.VSExtension.vsix"; + if (!File.Exists(filePath)) + { + context.Error("VSIX file not found!"); + return; + } + + var client = new HttpClient(); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes($":{pat}"))); + + using var fileStream = File.OpenRead(filePath); + using var content = new StreamContent(fileStream); + content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); + + var response = await client.PutAsync($"https://marketplace.visualstudio.com/_apis/gallery/publishers/{publisher}/vsextensions/{extensionName}/versions", content); + + if (response.IsSuccessStatusCode) + { + context.Information("Successfully uploaded the VSIX to the Visual Studio Marketplace."); + } + else + { + context.Error($"Failed to upload VSIX. Response: {response.StatusCode} - {response.ReasonPhrase}"); + } + } +} diff --git a/build/DeployTasks/DownloadArtifactsTask.cs b/build/DeployTasks/DownloadArtifactsTask.cs index ff014c846a1..836e55e4e85 100644 --- a/build/DeployTasks/DownloadArtifactsTask.cs +++ b/build/DeployTasks/DownloadArtifactsTask.cs @@ -11,5 +11,8 @@ public override async Task RunAsync(BuildContext context) context.CreateDirectory("nugets"); foreach (var os in new[] { "windows", "macos", "linux" }) await context.GitHubActions().Commands.DownloadArtifact($"nuget-{os}", "nugets"); + + context.CreateDirectory("vsix"); + await context.GitHubActions().Commands.DownloadArtifact("MonoGame.Templates.VSExtension.vsix", "vsix"); } } diff --git a/build/DeployTasks/UploadArtifactsTask.cs b/build/DeployTasks/UploadArtifactsTask.cs index 61abf7eceef..946b6693c0f 100644 --- a/build/DeployTasks/UploadArtifactsTask.cs +++ b/build/DeployTasks/UploadArtifactsTask.cs @@ -19,6 +19,12 @@ public override async Task RunAsync(BuildContext context) await context.GitHubActions().Commands.UploadArtifact(new DirectoryPath(System.IO.Path.Combine(context.BuildOutput, "Tests", "Tools", "Release")), $"tests-tools-{os}"); await context.GitHubActions().Commands.UploadArtifact(new DirectoryPath(System.IO.Path.Combine(context.BuildOutput, "Tests", "DesktopGL", "Release")), $"tests-desktopgl-{os}"); if (context.IsRunningOnWindows()) + { await context.GitHubActions().Commands.UploadArtifact(new DirectoryPath(System.IO.Path.Combine(context.BuildOutput, "Tests", "WindowsDX", "Release")), $"tests-windowsdx-{os}"); + + // Assuming that the .vsix file has already been created and is located at this exact path. + var vsixFilePath = System.IO.Path.Combine(context.BuildOutput, "MonoGame.Templates.VSExtension", "net472", "MonoGame.Templates.VSExtension.vsix"); + await context.GitHubActions().Commands.UploadArtifact(new FilePath(vsixFilePath), "MonoGame.Templates.VSExtension.vsix"); + } } } diff --git a/build/Tasks.cs b/build/Tasks.cs index d9a4bd3af55..cfa8c119e68 100644 --- a/build/Tasks.cs +++ b/build/Tasks.cs @@ -39,6 +39,7 @@ public sealed class BuildAllTask : FrostingTask { } [TaskName("Deploy")] [IsDependentOn(typeof(DeployNuGetsToGitHubTask))] [IsDependentOn(typeof(DeployNuGetsToNuGetOrgTask))] +[IsDependentOn(typeof(DeployVsixToMarketplaceTask))] public sealed class DeployTask : FrostingTask { } [TaskName("Test")]