Skip to content

Commit

Permalink
Get rid of the shit that broke everything
Browse files Browse the repository at this point in the history
  • Loading branch information
dgmjr committed Nov 30, 2024
1 parent e0244eb commit 991d8ff
Show file tree
Hide file tree
Showing 17 changed files with 280 additions and 10 deletions.
4 changes: 4 additions & 0 deletions Dgmjr.Build.NoTargets/Dgmjr.Build.NoTargets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<IsUsingNETSDK>true</IsUsingNETSDK>
<!-- <PackageVersionOverride Condition="'$(PackageVersionOverride)' == '' And '$(Configuration)' != 'Local'">0.0.23</PackageVersionOverride> -->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dgmjr.NET.Sdk.Tasks" />
</ItemGroup>
<ItemGroup>
<PackageFile Include="./Assets/*" PackagePath="Assets/%(Filename)%(Extension)" />
<PackageFile Include="./Common/*.cs" PackagePath="Common/%(Filename)%(Extension)" />
Expand All @@ -58,6 +61,7 @@
<EmbeddedResource Include="./Assets/README_TEMPLATE.md" LogicalName="%(Filename)%(Extension)" />
<EmbeddedResource Include="./Assets/frontmatter_template.yml" LogicalName="%(Filename)%(Extension)" />
<EmbeddedResource Include="./Assets/icon.png" LogicalName="DEFAULT_PACKAGE_ICON.png" />
<EmbeddedResource Include="./Assets/README.md" LogicalName="%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="YamlDotNet" />
Expand Down
14 changes: 14 additions & 0 deletions Dgmjr.Build.NoTargets/README.md
Original file line number Diff line number Diff line change
@@ -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
82 changes: 82 additions & 0 deletions Dgmjr.NET.Sdk.Tasks/Assets/README.md
Original file line number Diff line number Diff line change
@@ -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
<Include Sdk="DgmjrSdk" File="Sdk.props" />
```

And put the following code in your `Directory.Build.targets` file:

```xml
<Include Sdk="DgmjrSdk" File="Sdk.targets" />
```

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
7 changes: 7 additions & 0 deletions Dgmjr.NET.Sdk.Tasks/Assets/README_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
---
# ${title}

${description}

<!-- TODO: Write the rest of this file! -->
Binary file added Dgmjr.NET.Sdk.Tasks/Assets/dgmjr.pub
Binary file not shown.
12 changes: 12 additions & 0 deletions Dgmjr.NET.Sdk.Tasks/Assets/dgmjr.pub.asc
Original file line number Diff line number Diff line change
@@ -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
Binary file added Dgmjr.NET.Sdk.Tasks/Assets/dgmjr.snk
Binary file not shown.
21 changes: 21 additions & 0 deletions Dgmjr.NET.Sdk.Tasks/Assets/frontmatter_template.yml
Original file line number Diff line number Diff line change
@@ -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. <[email protected]>
# 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
---
Binary file added Dgmjr.NET.Sdk.Tasks/Assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Dgmjr.NET.Sdk.Tasks/Assets/icon.xcf
Binary file not shown.
86 changes: 86 additions & 0 deletions Dgmjr.NET.Sdk.Tasks/Dgmjr.NET.Sdk.Tasks.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!--
* Dgmjr.NET.Sdk.Tasks.csproj
* Created: 2024-11-27T02:20:59-05:00
* Modified: 2024-11-27T02:20:59-05:00
* Author: David G. Moore, Jr. <[email protected]>
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved
* License: MIT (https://opensource.org/licenses/MIT)
-->

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ProjectGuid>EB008C4C-9C3A-4498-A19D-34A42B6E2CE1</ProjectGuid>
<ProjectTypeGuid>FAE04EC0-301F-11D3-BF4B-00C04F79EFBC</ProjectTypeGuid>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<IsNuGetized>true</IsNuGetized>
<IsPackable>true</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(MSBuildThisFileDirectory)lib</OutputPath>
</PropertyGroup>
<PropertyGroup>
<Title>The DGMJR-IO SDK</Title>
<Description>The DGMJR-IO SDK is a collection of `.props` and `.targets` files that are used to build and package the DGMJR projects.</Description>
<!-- <TargetFrameworks>netstandard1.0;netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net7.0;net8.0</TargetFrameworks> -->
<PackageId>$(MSbuildProjectName)</PackageId>
<LangVersion>preview</LangVersion>
<PackageType>MSBuildSdk</PackageType>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<IncludeInSolutionFile>true</IncludeInSolutionFile>
<DevelopmentDependency>true</DevelopmentDependency>
<NoWarn>$(NoWarn);MSB4011</NoWarn>
<PackageIcon>icon.png</PackageIcon>
<IsUsingNETSDK>true</IsUsingNETSDK>
<!-- <PackageVersionOverride Condition="'$(PackageVersionOverride)' == '' And '$(Configuration)' != 'Local'">0.0.23</PackageVersionOverride> -->
</PropertyGroup>
<ItemGroup>
<PackageFile Include="./Assets/*" PackagePath="Assets/%(Filename)%(Extension)" />
<PackageFile Include="./Common/*.cs" PackagePath="Common/%(Filename)%(Extension)" />
<PackageFile Include="./Common/*.props" PackagePath="Common/%(Filename)%(Extension)" />
<PackageFile Include="./Targets/*.targets" PackagePath="Targets/%(Filename)%(Extension)" />
<PackageFile Include="./LICENSE.md" PackagePath="%(Filename)%(Extension)" />
<PackageFile Include="./Sdk/*" PackagePath="Sdk/%(Filename)%(Extension)" />
<PackageFile Include="./lib/*.dll" PackagePath="lib/%(Filename)%(Extension)" />
<PackageFile Include="./lib/*.dll" Pack="true" PackagePath="lib/$(TargetFramework)/%(Filename)%(Extension)" />
<PackageFile Include="./lib/**/*.dll" Pack="true" PackagePath="lib/netstandard2.0/%(Filename)%(Extension)" />
</ItemGroup>
<Target Name="PrepareGitConstants" />
<Target Name="GitInfo" />
<ItemGroup>
<PackageTag Include="sdk" Visible="false" />
<PackageTag Include="build-defaults" Visible="false" />
<PackageTag Include="dgmjrsdk" Visible="false" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="./LICENSE.md" LogicalName="%(Filename)%(Extension)" />
<EmbeddedResource Include="./Assets/README_TEMPLATE.md" LogicalName="%(Filename)%(Extension)" />
<EmbeddedResource Include="./Assets/frontmatter_template.yml" LogicalName="%(Filename)%(Extension)" />
<EmbeddedResource Include="./Assets/icon.png" LogicalName="DEFAULT_PACKAGE_ICON.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="YamlDotNet" />
<UsingsPackageReference Include="MSBuild.Usings" />
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<!-- <Using Include="System.Collections.Generic.IDictionary&lt;string,string&gt;" Alias="IStringDictionary" />
<Using Include="System.Collections.Generic.Dictionary&lt;string,string&gt;" Alias="StringDictionary" />
<Using Include="System.Collections.Generic.KeyValuePair&lt;string,string&gt;" Alias="StrKvp" /> -->
<Using Include="Dgmjr.Sdk.Models" />
<Using Include="System.Text.RegularExpressions" />
<Using Include="System.String" Static="true" />
<Using Include="System.IO.File" Static="true" />
<Using Include="System.IO.Path" Static="true" />
<Using Include="Microsoft.Build.Framework" />
<Using Include="Microsoft.Build.Execution" />
<Using Include="System.Runtime.CompilerServices" />
<Using Include="System.Reflection" />
<Using Include="System.Diagnostics" />
</ItemGroup>
<PropertyGroup>
<PushLocalIsEnabled>true</PushLocalIsEnabled>
<PushFaGetIsEnabled>true</PushFaGetIsEnabled>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Build.Framework;

namespace Dgmjr.NoTargets.Sdk.Tasks
namespace Dgmjr.Sdk.Tasks
{
///<summary>Task to ensure that a license file exists within the project directory.</summary>
public class EnsureLicenseFileExists : MSBTask
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Dgmjr.NoTargets.Sdk.Tasks;
namespace Dgmjr.Sdk.Tasks;

using Internal;
using Microsoft.Build.Framework;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
24 changes: 24 additions & 0 deletions Dgmjr.NET.Sdk.Tasks/LICENSE.md
Original file line number Diff line number Diff line change
@@ -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:[email protected] "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.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Dgmjr.NoTargets.Sdk.Models;
namespace Dgmjr.Sdk.Models;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Serialization;
Expand Down Expand Up @@ -106,6 +106,10 @@ public class ReadmeFrontMatter
[YamlMember(Alias = "type", DefaultValuesHandling = OmitNull | OmitEmptyCollections)]
public string DocumentType { get; set; } = "readme";

///<summary>the document's copyright notice</summary>
[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<string, string>();
}
Expand Down Expand Up @@ -134,6 +138,14 @@ public class UrlYamlConverter : IYamlTypeConverter
: null;
}

public object? ReadYaml(IParser parser, type type, ObjectDeserializer rootDeserializer)
{
var value = parser.Consume<Scalar>().Value;
return Uri.TryCreate(value, UriKind.Absolute, out var uri)
? uri
: null;
}

/// <inheritdoc />
public void WriteYaml(IEmitter emitter, object? value, Type type)
{
Expand All @@ -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));
}
}
}
Binary file added Dgmjr.NET.Sdk.Tasks/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 991d8ff

Please sign in to comment.