diff --git a/Dgmjr.Build.NoTargets/Dgmjr.Build.NoTargets.csproj b/Dgmjr.Build.NoTargets/Dgmjr.Build.NoTargets.csproj index 56cc55c..49e8a37 100644 --- a/Dgmjr.Build.NoTargets/Dgmjr.Build.NoTargets.csproj +++ b/Dgmjr.Build.NoTargets/Dgmjr.Build.NoTargets.csproj @@ -34,6 +34,9 @@ true + + + @@ -58,6 +61,7 @@ + diff --git a/Dgmjr.Build.NoTargets/README.md b/Dgmjr.Build.NoTargets/README.md new file mode 100644 index 0000000..d7f4381 --- /dev/null +++ b/Dgmjr.Build.NoTargets/README.md @@ -0,0 +1,14 @@ +--- +authors: +- dgmjr +title: README.md +lastmod: 2024-11-25T12:11:10-05:00 +date: 2024-11-25T12:11:10-05:00 +license: MIT +copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved +keywords: +- dgmjr +type: readme +--- + +# Dgmjr.Build.NoTargets diff --git a/Dgmjr.NET.Sdk.Tasks/Assets/README.md b/Dgmjr.NET.Sdk.Tasks/Assets/README.md new file mode 100644 index 0000000..4922749 --- /dev/null +++ b/Dgmjr.NET.Sdk.Tasks/Assets/README.md @@ -0,0 +1,82 @@ +--- +title: DGMJR-IO SDK +authors: +- dgmjr +type: readme +slug: dgmjr-io-sdk +project: shared +description: The DGMJR-IO SDK is a collection of `.props` and `.targets` files that are used to build and package the DGMJR projects. It sets a whole boatload of default values and does a shit ton of stuff automagically. +version: 0.0.1-Local +lastmod: 2023-07-14T07:49:58.705Z +date: 2023-07-14T07:49:16.139Z +license: MIT +keywords: +- dotnet +- sdk +- dgmjrsdk +- defaults +- default-values +--- + +# DGMJR-IO SDK + +The DGMJR-IO SDK is a collection of `.props` and `.targets` files that are used to build and package the DGMJR projects. It sets a whole boatload of default values and does a shit ton of stuff automagically. + +# Getting Started + +Put the following code in your `Directory.Build.props` file: + +```xml + +``` + +And put the following code in your `Directory.Build.targets` file: + +```xml + +``` + +And make sure to add the following to your `global.json` file: + +```json +"msbuild-sdks":{ + "DgmjrSdk": "0.0.1" // (or the current package version) +} +``` + +Then compile and run your project and it will have all the DGMJR-IO SDK defaults. These include the following: + +## Item Definitions + +* `Author` - with `Initials` and `Email` metadata, which populate the `Authors` property of the MSBuild (and NuGet) project +* `Owner` - with `Initials` and `Email` metadata, which populate the `Owners` and `Copyright` properties of the MSBuild (and NuGet) project +* `PackageTag` - which concatenates all instances of it and populates the `PackageTags` property of the MSBuild (and NuGet) project +* `SourceCodeReference`, which behaves just like a `PackageReference` except it just pulls the `ContentFiles` and `Build` assets from the package +* `SourceGenerator`, which behaves just like a `PackageReference` except it just pulls the `Analyzers` and `Build` assets from the package +* `NoWarn`, which adds all instances to the `NoWarn` property + +## Targets + +* [`EnsurePackageReadme`](https://github.com/dgmjr-io/DgmjrSdk/blob/main/src/Build/PackageReadme.targets), which ensures the package contains a `README.md` file at the root; if not, it generates one from the `Title` and `Description` properties and embeds it into the NuGet package +* [`EnsurePackageIcon`](https://github.com/dgmjr-io/DgmjrSdk/blob/main/src/Build/PackageIcon.targets), which ensures the package contains an icon file; if theres no file named `Icon.(png/jpg/jpeg)` at the root, it will use a [default icon](https://github.com/dgmjr-io/DgmjrSdk/blob/main/src/Assets/Icon.png) +* [`RemoveDuplicateUsings`](https://github.com/dgmjr-io/DgmjrSdk/blob/main/src/Build/RemoveDuplicateUsings.targets), which removes any duplicate `Using` items from the project +* [`RemoveDuplicatePackageReferences`](https://github.com/dgmjr-io/DgmjrSdk/blob/main/src/Build/RemoveDuplicatePackageReferences.targets), which removes any duplicate `Using` items from the project +* [`PackageProjectName.targets`](https://github.com/dgmjr-io/DgmjrSdk/blob/main/src/Build/PackageProjectName.targets) - a file that packages any file in the root directory named `[MSBuildProjectName].targets` into the `build` folder of the NuGet package +* [`PackageProjectName.props`](https://github.com/dgmjr-io/DgmjrSdk/blob/main/src/Build/PackageProjectName.targets) - a file that packages any file in the root directory named `[MSBuildProjectName].props` into the `build` folder of the NuGet package + +## Properties + +* [`PackageVersionOverride`](https://github.com/dgmjr-io/DgmjrSdk/blob/main/src/Build/PackageVersionOverride.props), which allows you to override the package version calculated by `MinVer` +* A default `UserSecrets` property +* Default `AssetTargetFallback`s for all .NET versions from .NETStandard 2.0 through .NET 8.0 +* Default values for generating XML documentation as well as pulling the XML docs from referenced packages +* All `Include[Whatever]OutputGroup` properties set to `true` +* [`JustInTimeVersioning`](https://github.com/dgmjr-io/JustInTimeVersioning) enabled +* [`NuGetPush`](https://github.com/dgmjr-io/NuGetPush) enabled + +# Miscellaneous + +* Assembly signing - ensures the assembly is signed by a key called [`dgmjr.snk`](https://github.com/dgmjr-io/DgmjrSdk/blob/main/src/Assets/dgmjr.snk) located in the [`Assets`](https://github.com/dgmjr-io/DgmjrSdk/blob/main/src/Assets) folder. There's also [`dgmjr.pub`](https://github.com/dgmjr-io/DgmjrSdk/blob/main/src/Assets/dgmjr.pub) (the binary version of the public key) and [`dgmjr.pub.asc`](https://github.com/dgmjr-io/DgmjrSdk/blob/main/src/Assets/dgmjr.pub.asc), which contains the plain text public key and token. +* [`TestingLocal`](https://github.com/dgmjr-io/DgmjrSdk/blob/main/src/Build/TestingLocal.targets) - Overrides the `AssemblyVersion` attribute to always be `0.0.1-Local` when the `Configuration` is set to `Local` +* [`Icon.png`](https://github.com/dgmjr-io/DgmjrSdk/blob/main/src/Assets/Icon.png), a default icon file, which will be applied to any package that doesn't have one. +* [`NuGetizer`](https://github.com/devlooped/nugetizer) enabled by default diff --git a/Dgmjr.NET.Sdk.Tasks/Assets/README_TEMPLATE.md b/Dgmjr.NET.Sdk.Tasks/Assets/README_TEMPLATE.md new file mode 100644 index 0000000..a969a24 --- /dev/null +++ b/Dgmjr.NET.Sdk.Tasks/Assets/README_TEMPLATE.md @@ -0,0 +1,7 @@ +--- +--- +# ${title} + +${description} + + diff --git a/Dgmjr.NET.Sdk.Tasks/Assets/dgmjr.pub b/Dgmjr.NET.Sdk.Tasks/Assets/dgmjr.pub new file mode 100644 index 0000000..52df41b Binary files /dev/null and b/Dgmjr.NET.Sdk.Tasks/Assets/dgmjr.pub differ diff --git a/Dgmjr.NET.Sdk.Tasks/Assets/dgmjr.pub.asc b/Dgmjr.NET.Sdk.Tasks/Assets/dgmjr.pub.asc new file mode 100644 index 0000000..9fc7277 --- /dev/null +++ b/Dgmjr.NET.Sdk.Tasks/Assets/dgmjr.pub.asc @@ -0,0 +1,12 @@ +Mono StrongName - version 6.12.0.182 +StrongName utility for signing assemblies +Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed. + +Public Key: +00240000048000009400000006020000002400005253413100040000010001000d802c8a5e6d2d +2a7487bf92dd89a0689f004d27d8eaef54cc62aed0afd643dc33222f020003d3fc79c76c0a791e +b7ae56d0d17bac639122f17a8f7f246ae6481045146327ebc0eab8878dbdc79aa6ad1bc26b56bb +e0ce5eb443c7450a3496d8bc181135c01b98e974ef825ea9b247bd4bc95023b9394e7073e278cd +e1ca0c94 + +Public Key Token: 44326fa453475ade diff --git a/Dgmjr.NET.Sdk.Tasks/Assets/dgmjr.snk b/Dgmjr.NET.Sdk.Tasks/Assets/dgmjr.snk new file mode 100644 index 0000000..c1bceeb Binary files /dev/null and b/Dgmjr.NET.Sdk.Tasks/Assets/dgmjr.snk differ diff --git a/Dgmjr.NET.Sdk.Tasks/Assets/frontmatter_template.yml b/Dgmjr.NET.Sdk.Tasks/Assets/frontmatter_template.yml new file mode 100644 index 0000000..12ddde0 --- /dev/null +++ b/Dgmjr.NET.Sdk.Tasks/Assets/frontmatter_template.yml @@ -0,0 +1,21 @@ +# +# frontmatter_template.yml +# Created: 2024-06-25T18:02:42-04:00 +# Modified: 2024-06-25T18:02:42-04:00 +# Author: David G. Moore, Jr. +# Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved +# License: MIT (https://opensource.org/licenses/MIT) +# + +--- +authors: + - authors +description: description +keywords: keywords +license: license +slug: slug +tags: targ +title: title +type: readme +version: version +--- diff --git a/Dgmjr.NET.Sdk.Tasks/Assets/icon.png b/Dgmjr.NET.Sdk.Tasks/Assets/icon.png new file mode 100644 index 0000000..db07a03 Binary files /dev/null and b/Dgmjr.NET.Sdk.Tasks/Assets/icon.png differ diff --git a/Dgmjr.NET.Sdk.Tasks/Assets/icon.xcf b/Dgmjr.NET.Sdk.Tasks/Assets/icon.xcf new file mode 100644 index 0000000..ee3dd67 Binary files /dev/null and b/Dgmjr.NET.Sdk.Tasks/Assets/icon.xcf differ diff --git a/Dgmjr.NET.Sdk.Tasks/Dgmjr.NET.Sdk.Tasks.csproj b/Dgmjr.NET.Sdk.Tasks/Dgmjr.NET.Sdk.Tasks.csproj new file mode 100644 index 0000000..63a38fb --- /dev/null +++ b/Dgmjr.NET.Sdk.Tasks/Dgmjr.NET.Sdk.Tasks.csproj @@ -0,0 +1,86 @@ + + + + + netstandard2.0 + EB008C4C-9C3A-4498-A19D-34A42B6E2CE1 + FAE04EC0-301F-11D3-BF4B-00C04F79EFBC + true + true + true + true + false + $(MSBuildThisFileDirectory)lib + + + The DGMJR-IO SDK + The DGMJR-IO SDK is a collection of `.props` and `.targets` files that are used to build and package the DGMJR projects. + + $(MSbuildProjectName) + preview + MSBuildSdk + true + true + true + $(NoWarn);MSB4011 + icon.png + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + + diff --git a/Dgmjr.Build.NoTargets/Tasks/EnsureLicenseFileExists.cs b/Dgmjr.NET.Sdk.Tasks/EnsureLicenseFileExists.cs similarity index 95% rename from Dgmjr.Build.NoTargets/Tasks/EnsureLicenseFileExists.cs rename to Dgmjr.NET.Sdk.Tasks/EnsureLicenseFileExists.cs index f547ace..3131057 100644 --- a/Dgmjr.Build.NoTargets/Tasks/EnsureLicenseFileExists.cs +++ b/Dgmjr.NET.Sdk.Tasks/EnsureLicenseFileExists.cs @@ -1,6 +1,6 @@ using Microsoft.Build.Framework; -namespace Dgmjr.NoTargets.Sdk.Tasks +namespace Dgmjr.Sdk.Tasks { ///Task to ensure that a license file exists within the project directory. public class EnsureLicenseFileExists : MSBTask diff --git a/Dgmjr.Build.NoTargets/Tasks/EnsurePackageIcon.cs b/Dgmjr.NET.Sdk.Tasks/EnsurePackageIcon.cs similarity index 95% rename from Dgmjr.Build.NoTargets/Tasks/EnsurePackageIcon.cs rename to Dgmjr.NET.Sdk.Tasks/EnsurePackageIcon.cs index ae2c3c3..19be5cc 100644 --- a/Dgmjr.Build.NoTargets/Tasks/EnsurePackageIcon.cs +++ b/Dgmjr.NET.Sdk.Tasks/EnsurePackageIcon.cs @@ -1,4 +1,4 @@ -namespace Dgmjr.NoTargets.Sdk.Tasks; +namespace Dgmjr.Sdk.Tasks; using Internal; using Microsoft.Build.Framework; diff --git a/Dgmjr.Build.NoTargets/Tasks/EnsurePackageReadmeFileExists.cs b/Dgmjr.NET.Sdk.Tasks/EnsurePackageReadmeFileExists.cs similarity index 88% rename from Dgmjr.Build.NoTargets/Tasks/EnsurePackageReadmeFileExists.cs rename to Dgmjr.NET.Sdk.Tasks/EnsurePackageReadmeFileExists.cs index f040f04..42bf6e5 100644 --- a/Dgmjr.Build.NoTargets/Tasks/EnsurePackageReadmeFileExists.cs +++ b/Dgmjr.NET.Sdk.Tasks/EnsurePackageReadmeFileExists.cs @@ -1,4 +1,4 @@ -namespace Dgmjr.NoTargets.Sdk.Tasks; +namespace Dgmjr.Sdk.Tasks; using static System.Text.RegularExpressions.RegexOptions; using MSBTask = Microsoft.Build.Utilities.Task; @@ -9,7 +9,7 @@ namespace Dgmjr.NoTargets.Sdk.Tasks; using Microsoft.Build.Execution; using static System.IO.File; using static System.String; -using Dgmjr.NoTargets.Sdk.Models; +using Dgmjr.Sdk.Models; using System.IO; using System; @@ -40,13 +40,13 @@ public override bool Execute() { if (!Exists(PackageReadmePath)) { - // Log.LogMessage($"Creating {README_MD}..."); - // WriteAllText(PackageReadmePath, GetReadmeContent()); + Log.LogMessage($"Creating {README_MD}..."); + WriteAllText(PackageReadmePath, GetReadmeContent()); } else { - // Log.LogMessage($"Updating {README_MD}..."); - // WriteAllText(PackageReadmePath, GetReadmeContent()); + Log.LogMessage($"Updating {README_MD}..."); + WriteAllText(PackageReadmePath, GetReadmeContent()); } return true; } @@ -102,7 +102,7 @@ out var projectUri return readmeMarkdown.Replace(frontmatterYaml, newFrontmatterYaml); } - private string GetFrontMatter(string readmeMarkdown) + private static string GetFrontMatter(string readmeMarkdown) { return FrontmatterRegex.Match(readmeMarkdown).Groups["frontmatter"].Value; } diff --git a/Dgmjr.NET.Sdk.Tasks/LICENSE.md b/Dgmjr.NET.Sdk.Tasks/LICENSE.md new file mode 100644 index 0000000..ad48430 --- /dev/null +++ b/Dgmjr.NET.Sdk.Tasks/LICENSE.md @@ -0,0 +1,24 @@ +--- +title: MIT License +description: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files..yadda, yadda, yadda... +keywords: + - license + - mit + - IP + - copyright +lastmod: 2023-08-29T17:14:54.338Z +date: 2023-07-13T05:44:46.048Z +license: MIT +type: license +slug: mit-license +--- + +# MIT License + +Copyright (c) 2022-2023 [David G. Moore, Jr.](mailto:david@dgmjr.io "Send David an email") ([@dgmjr](https://github.com/dgmjr "Contact david on GitHub")), All Rights Reserved + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Dgmjr.Build.NoTargets/Tasks/ReadmeFrontMatter.cs b/Dgmjr.NET.Sdk.Tasks/ReadmeFrontMatter.cs similarity index 83% rename from Dgmjr.Build.NoTargets/Tasks/ReadmeFrontMatter.cs rename to Dgmjr.NET.Sdk.Tasks/ReadmeFrontMatter.cs index f0dc611..ea7c1a2 100644 --- a/Dgmjr.Build.NoTargets/Tasks/ReadmeFrontMatter.cs +++ b/Dgmjr.NET.Sdk.Tasks/ReadmeFrontMatter.cs @@ -1,4 +1,4 @@ -namespace Dgmjr.NoTargets.Sdk.Models; +namespace Dgmjr.Sdk.Models; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Serialization; @@ -106,6 +106,10 @@ public class ReadmeFrontMatter [YamlMember(Alias = "type", DefaultValuesHandling = OmitNull | OmitEmptyCollections)] public string DocumentType { get; set; } = "readme"; + ///the document's copyright notice + [YamlMember(Alias = "copyright", DefaultValuesHandling = OmitNull | OmitEmptyCollections)] + public string Copyright { get; set; } = "© " + DateTimeOffset.UtcNow.Year; + // [YamlMember(Alias = "additionalValues", DefaultValuesHandling = OmitNull | OmitEmptyCollections)] // public IStringDictionary AdditionalValues { get; set; } = new Dictionary(); } @@ -134,6 +138,14 @@ public class UrlYamlConverter : IYamlTypeConverter : null; } + public object? ReadYaml(IParser parser, type type, ObjectDeserializer rootDeserializer) + { + var value = parser.Consume().Value; + return Uri.TryCreate(value, UriKind.Absolute, out var uri) + ? uri + : null; + } + /// public void WriteYaml(IEmitter emitter, object? value, Type type) { @@ -142,4 +154,12 @@ public void WriteYaml(IEmitter emitter, object? value, Type type) emitter.Emit(new Scalar(null, null, uri.ToString(), ScalarStyle.Any, true, false)); } } + + public void WriteYaml(IEmitter emitter, object? value, type type, ObjectSerializer serializer) + { + if (value is Uri uri) + { + emitter.Emit(new Scalar(null, null, uri.ToString(), ScalarStyle.Any, true, false)); + } + } } diff --git a/Dgmjr.NET.Sdk.Tasks/icon.png b/Dgmjr.NET.Sdk.Tasks/icon.png new file mode 100755 index 0000000..e105d08 Binary files /dev/null and b/Dgmjr.NET.Sdk.Tasks/icon.png differ