diff --git a/.editorconfig b/.editorconfig index 8c2e20b4..c434eb53 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,17 +13,16 @@ indent_style = space indent_size = 4 # Xml project files -[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,msbuildproj,nuproj}] +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,msbuildproj,props,targets}] indent_size = 2 # Xml config files -[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] +[*.{ruleset,config,nuspec,resx,vsixmanifest,vsct}] indent_size = 2 # YAML files [*.{yaml,yml}] indent_size = 2 -indent_style = space # JSON files [*.json] @@ -51,16 +50,23 @@ dotnet_style_null_propagation = true:suggestion dotnet_style_explicit_tuple_names = true:suggestion # CSharp code style settings: + +# IDE0040: Add accessibility modifiers +dotnet_style_require_accessibility_modifiers = omit_if_default:error + +# IDE0040: Add accessibility modifiers +dotnet_diagnostic.IDE0040.severity = error + [*.cs] # Prefer "var" everywhere csharp_style_var_for_built_in_types = true:suggestion csharp_style_var_when_type_is_apparent = true:suggestion csharp_style_var_elsewhere = true:suggestion -# Prefer method-like constructs to have a block body -csharp_style_expression_bodied_methods = false:none -csharp_style_expression_bodied_constructors = false:none -csharp_style_expression_bodied_operators = false:none +# Prefer method-like constructs to have an expression-body +csharp_style_expression_bodied_methods = true:none +csharp_style_expression_bodied_constructors = true:none +csharp_style_expression_bodied_operators = true:none # Prefer property-like constructs to have an expression-body csharp_style_expression_bodied_properties = true:none @@ -68,8 +74,8 @@ csharp_style_expression_bodied_indexers = true:none csharp_style_expression_bodied_accessors = true:none # Suggest more modern language features when available -csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion -csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true:error +csharp_style_pattern_matching_over_as_with_null_check = true:error csharp_style_inlined_variable_declaration = true:suggestion csharp_style_throw_expression = true:suggestion csharp_style_conditional_delegate_call = true:suggestion diff --git a/.gitattributes b/.gitattributes index 1ff0c423..7c375796 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,63 +1,24 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto +# sln, csproj files (and friends) are always CRLF, even on linux +*.sln text eol=crlf +*.proj text eol=crlf +*.csproj text eol=crlf -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp +# These are windows specific files which we may as well ensure are +# always crlf on checkout +*.bat text eol=crlf +*.cmd text eol=crlf -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary +# Opt in known filetypes to always normalize line endings on checkin +# and always use native endings on checkout +*.c text +*.config text +*.h text +*.cs text +*.md text +*.tt text +*.txt text -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain +# Some must always be checked out as lf so enforce that for those files +# If these are not lf then bash/cygwin on windows will not be able to +# excute the files +*.sh text eol=lf \ No newline at end of file diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..ef77f215 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +custom: https://paypal.me/kzu +patreon: danielkzu +open_collective: kzu +liberapay: kzu diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 00000000..67f75950 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,50 @@ +--- +name: Bug Report +about: Create a report to help us fix a problem. +title: '' +labels: 'bug' +assignees: '' +--- + +## Describe the Bug + + + +## Steps to Reproduce + + + +```c# +public class ReproTest +{ + [Fact] + public void Repro() + { + // arrange + + // act + + // assert + } +} +``` + +## Expected Behavior + + + +## Exception with Stack Trace + + + +```text +Put the exception with stack trace here. +``` + +## Version Info + + + +## Additional Info + + diff --git a/.github/ISSUE_TEMPLATE/feature.md b/.github/ISSUE_TEMPLATE/feature.md new file mode 100644 index 00000000..0b3de9db --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.md @@ -0,0 +1,33 @@ +--- +name: Feature Request +about: Suggest an idea to make the project better. +title: '' +labels: 'enhancement' +assignees: '' +--- + +## Problem Statement + + + +## Desired Solution + + + +## Alternatives You've Considered + + + +## Additional Context + + diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..9bd97000 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: +- package-ecosystem: nuget + directory: / + schedule: + interval: weekly \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c7ae88b..deaaf150 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,12 @@ -๏ปฟname: build -on: push +๏ปฟ# Builds and runs tests in all three supported OSes +# Pushes CI feed if secrets.SLEET_CONNECTION is provided + +name: build +on: + push: + branches: [ main, dev, 'feature/*', 'rel/*' ] + pull_request: + types: [opened, synchronize, reopened] env: DOTNET_NOLOGO: true @@ -11,39 +18,51 @@ jobs: steps: - name: ๐Ÿค˜ checkout uses: actions/checkout@v2 - - name: ๐Ÿ–‰ version - run: echo "VERSION_SUFFIX=$(git name-rev --name-only --refs=refs/heads/* HEAD).$GITHUB_RUN_NUMBER" >> $GITHUB_ENV - shell: bash - name: โš™ dotnet 5.0.x uses: actions/setup-dotnet@v1 with: dotnet-version: 5.0.x + - name: โš™ dotnet 3.1.x + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.x - name: โš™ dotnet 2.1.x uses: actions/setup-dotnet@v1 with: dotnet-version: 2.1.x - - name: โš™ dotnet 3.1.x - uses: actions/setup-dotnet@v1 + + - name: โœ“ check formatting + run: | + dotnet tool update -g --version 4.1.* dotnet-format + dotnet format -f src --check -v:diag + + - name: ๐Ÿ” msbuild + uses: microsoft/setup-msbuild@v1 with: - dotnet-version: 3.1.x - - name: ๐Ÿ”ฝ dotnet-vs - run: dotnet tool update -g dotnet-vs - - name: ๐Ÿ” vs 16.8+ - run: echo "MSB=$(vs where --prop=InstallationPath --first -version 16.8)" >> $GITHUB_ENV - shell: bash - - name: ๐Ÿ”ฝ vs community - run: vs install community --quiet +Microsoft.VisualStudio.Component.ManagedDesktop.Core +Microsoft.NetCore.Component.DevelopmentTools - if: env.MSB == '' - - name: โ‰ฅ msbuild - run: echo "$(vs where --prop=InstallationPath --first -version 16.8)\MSBuild\Current\Bin" >> $GITHUB_PATH - shell: bash + vs-version: '[16.8,)' + - name: ๐Ÿ™ build - run: msbuild -r -p:versionsuffix=$($env:VERSION_SUFFIX) + run: msbuild -r -m:1 -bl:build.binlog -p:VersionLabel="$($env:GITHUB_REF).$($env:GITHUB_RUN_NUMBER)" + - name: ๐Ÿงช test run: msbuild -t:test + - name: ๐Ÿ“ฆ pack - run: msbuild -t:pack -p:nobuild=true -p:versionsuffix=$($env:VERSION_SUFFIX) + run: msbuild -t:pack -p:nobuild=true -m:1 -bl:pack.binlog -p:VersionLabel="$($env:GITHUB_REF).$($env:GITHUB_RUN_NUMBER)" + + - name: ๐Ÿ”ผ logs + if: always() + uses: actions/upload-artifact@v2 + with: + path: | + *.binlog + logs/**/*.* + + # Only push CI package to sleet feed if building on ubuntu (fastest) - name: ๐Ÿš€ sleet + env: + SLEET_CONNECTION: ${{ secrets.SLEET_CONNECTION }} + if: env.SLEET_CONNECTION != '' run: | dotnet tool install -g --version 3.2.0 sleet - sleet push bin --config none -f --verbose -p "SLEET_FEED_CONTAINER=nuget" -p "SLEET_FEED_CONNECTIONSTRING=${{ secrets.SLEET_CONNECTION }}" -p "SLEET_FEED_TYPE=azure" \ No newline at end of file + sleet push bin --config none -f --verbose -p "SLEET_FEED_CONTAINER=nuget" -p "SLEET_FEED_CONNECTIONSTRING=${{ secrets.SLEET_CONNECTION }}" -p "SLEET_FEED_TYPE=azure" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 53684737..e31d50ee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,11 +1,14 @@ -๏ปฟname: release +๏ปฟ# Builds a final release version and pushes to nuget.org +# whenever a release is published. +# Requires: secrets.NUGET_API_KEY + +name: release on: release: types: [published] env: DOTNET_NOLOGO: true - MSBUILDDISABLENODEREUSE: 1 Configuration: Release jobs: @@ -13,38 +16,41 @@ jobs: runs-on: windows-latest steps: - name: ๐Ÿค˜ checkout - uses: actions/checkout@v2 - - name: ๐Ÿ–‰ version - run: echo "VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV - shell: bash + uses: actions/checkout@v2 - name: โš™ dotnet 5.0.x uses: actions/setup-dotnet@v1 with: dotnet-version: 5.0.x + - name: โš™ dotnet 3.1.x + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.x - name: โš™ dotnet 2.1.x uses: actions/setup-dotnet@v1 with: dotnet-version: 2.1.x - - name: โš™ dotnet 3.1.x - uses: actions/setup-dotnet@v1 + + - name: ๐Ÿ” msbuild + uses: microsoft/setup-msbuild@v1 with: - dotnet-version: 3.1.x - - name: ๐Ÿ”ฝ dotnet-vs - run: dotnet tool update -g dotnet-vs - - name: ๐Ÿ” vs 16.8+ - run: echo "MSB=$(vs where --prop=InstallationPath --first -version 16.8)" >> $GITHUB_ENV - shell: bash - - name: ๐Ÿ”ฝ vs community - run: vs install community --quiet +Microsoft.VisualStudio.Component.ManagedDesktop.Core +Microsoft.NetCore.Component.DevelopmentTools - if: env.MSB == '' - - name: โ‰ฅ msbuild - run: echo "$(vs where --prop=InstallationPath --first -version 16.8)\MSBuild\Current\Bin" >> $GITHUB_PATH - shell: bash + vs-version: '[16.8,)' + - name: ๐Ÿ™ build - run: msbuild -r -p:version=$($env:VERSION) + run: msbuild -r -m:1 -bl:build.binlog -p:Version=${GITHUB_REF#refs/*/v} + shell: bash + - name: ๐Ÿงช test run: msbuild -t:test + - name: ๐Ÿ“ฆ pack - run: msbuild -t:pack -p:nobuild=true -p:version=$($env:VERSION) - - name: ๐Ÿš€ push - run: dotnet nuget push bin\**\*.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} --skip-duplicate \ No newline at end of file + run: msbuild -t:pack -p:nobuild=true -m:1 -bl:pack.binlog -p:Version=${GITHUB_REF#refs/*/v} + shell: bash + + - name: ๐Ÿ”ผ logs + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + path: '*.binlog' + + - name: ๐Ÿš€ nuget + run: dotnet nuget push ./bin/**/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} --skip-duplicate \ No newline at end of file diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 00000000..3f42147f --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,51 @@ +๏ปฟ# Creates a draft release whenever a tag v* is pushed, +# with a changelog from the previous tag. If the tag +# contains a label, the release is flagged as a prerelease. + +name: tag +on: + push: + tags: [ 'v*' ] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: ๐Ÿค˜ checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: ๐Ÿท current + run: echo "CURRENT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: ๐Ÿท since + run: echo "SINCE_TAG=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))" >> $GITHUB_ENV + - name: ๐Ÿšง prerelease + run: echo "PRERELEASE=true" >> $GITHUB_ENV + if: contains(env.CURRENT_TAG, '-') + + - name: โš™ changelog + uses: faberNovel/github-changelog-generator-action@master + if: env.SINCE_TAG != '' + with: + options: --token ${{ secrets.GITHUB_TOKEN }} --since-tag ${{ env.SINCE_TAG }} + + - name: โš™ changelog + uses: faberNovel/github-changelog-generator-action@master + if: env.SINCE_TAG == '' + with: + options: --token ${{ secrets.GITHUB_TOKEN }} + + - name: ๐Ÿ˜บ changelog + run: cat CHANGELOG.md + + - name: ๐Ÿ–‰ release + uses: actions/create-release@v1 + with: + release_name: ${{ env.CURRENT_TAG }} + tag_name: ${{ env.CURRENT_TAG }} + draft: true + prerelease: ${{ env.PRERELEASE }} + body_path: CHANGELOG.md + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github_changelog_generator b/.github_changelog_generator new file mode 100644 index 00000000..955932c7 --- /dev/null +++ b/.github_changelog_generator @@ -0,0 +1,4 @@ +usernames-as-github-logins=true +header-label= +add_issues_wo_labels=false +exclude-labels=dependencies,duplicate,question,invalid,wontfix \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2ed6a02a..23fe6bd6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,22 @@ -.nuget -.vs -.idea -out bin obj -*.nupkg -*.lock.json -*.nuget.props -*.nuget.targets +artifacts +pack +.vs +.vscode + *.suo +*.sdf +*.userprefs *.user +*.nupkg +*.metaproj +*.tmp *.cache -*.log *.binlog -*.rsp \ No newline at end of file +*.zip + +.nuget +*.lock.json +*.nuget.props +*.nuget.targets \ No newline at end of file diff --git a/.netconfig b/.netconfig new file mode 100644 index 00000000..f7b23d6d --- /dev/null +++ b/.netconfig @@ -0,0 +1,87 @@ +[file] + url = https://github.com/kzu/oss +[file ".netconfig"] + url = https://github.com/kzu/oss/blob/main/.netconfig + skip +[file "readme.md"] + url = https://github.com/kzu/oss/blob/main/readme.md + skip +[file "src/icon.png"] + url = https://github.com/kzu/oss/blob/main/src/icon.png + skip +[file ".editorconfig"] + url = https://github.com/kzu/oss/blob/main/.editorconfig + etag = 985aa022503959d35b03c870f07ae604cead7580d260775235ef6665aa9a6cbe + weak +[file ".gitattributes"] + url = https://github.com/kzu/oss/blob/main/.gitattributes + etag = 7acb32f5fa6d4ccd9c824605a7c2b8538497f0068c165567807d393dcf4d6bb7 + weak +[file ".github/FUNDING.yml"] + url = https://github.com/kzu/oss/blob/main/.github/FUNDING.yml + etag = dbc0e0c56e48bf06a70f50ba2fdaf6f048bb81ac8558b743c8e919487da3bfcf + weak +[file ".github/ISSUE_TEMPLATE/bug.md"] + url = https://github.com/kzu/oss/blob/main/.github/ISSUE_TEMPLATE/bug.md + etag = 026852ba1f1921f3a043bb5e09cd7a2c3d9a33ec51f48e524dc3a2ab72de3141 + weak +[file ".github/ISSUE_TEMPLATE/feature.md"] + url = https://github.com/kzu/oss/blob/main/.github/ISSUE_TEMPLATE/feature.md + etag = c5b7de1bc9eaf1f2ae6d1d2021e68084a5b1ab4800e9f129416d2838c128cad1 + weak +[file ".github/dependabot.yml"] + url = https://github.com/kzu/oss/blob/main/.github/dependabot.yml + etag = 2fc8a0d2b47091b058ae3e1f68333492044b49a684621f4939a0bce5bff869d5 + weak +[file ".github/workflows/build.yml"] + url = https://github.com/kzu/oss/blob/main/.github/workflows/build.yml + etag = c56db40b37f8dbcff13aea20eefc263caf825d17d86b0dc055ce504d8cb8ae9d + weak +[file ".github/workflows/release.yml"] + url = https://github.com/kzu/oss/blob/main/.github/workflows/release.yml + etag = fe4eae2bf3738645bca3b8f9f90ace482802fdd818c6d6651dccbb311ebeb231 + weak +[file ".github/workflows/tag.yml"] + url = https://github.com/kzu/oss/blob/main/.github/workflows/tag.yml + etag = 26e271cf76e00c6922552af104b1e496103bdfa75ebef253447594207b10153e + weak +[file ".github_changelog_generator"] + url = https://github.com/kzu/oss/blob/main/.github_changelog_generator + etag = a724e0cbbad99a04e6cd3738a5f3ec5416dd5f29ae7073e7afe5471e73107e42 + weak +[file ".gitignore"] + url = https://github.com/kzu/oss/blob/main/.gitignore + etag = 4698b35abed1f3941de6bed08bc80278c30569de3ead5b878b27b4bb79f8718a + weak +[file "Directory.Build.rsp"] + url = https://github.com/kzu/oss/blob/main/Directory.Build.rsp + etag = 6a6c6e1d3895df953abf14c82b0899e3eea75cdcd679f6212dcfea15183d73d6 + weak +[file "_config.yml"] + url = https://github.com/kzu/oss/blob/main/_config.yml + etag = c7f2063ead734d0afc383a07c35da2864a221311da8e1c0c6fea8939e932d2ab + weak +[file "code-of-conduct.md"] + url = https://github.com/kzu/oss/blob/main/code-of-conduct.md + etag = 4857c01bb695f09bf6912d778951c3065d9dd565e5de3d0827f40432d0e4c613 + weak +[file "license.txt"] + url = https://github.com/kzu/oss/blob/main/license.txt + etag = 2c6335b37e4ae05eea7c01f5d0c9d82b49c488f868a8b5ba7bff7c6ff01f3994 + weak +[file "security.md"] + url = https://github.com/kzu/oss/blob/main/security.md + etag = 80070e3a380796b13d180b82f43694eac9e7a29d8d2f8549ccb2920fd5c88828 + weak +[file "src/Directory.Build.props"] + url = https://github.com/kzu/oss/blob/main/src/Directory.Build.props + etag = d0b93d7533832a4d62cff69c71540bad3284bf92a7d2096b1a91607d72099d2b + weak +[file "src/Directory.Build.targets"] + url = https://github.com/kzu/oss/blob/main/src/Directory.Build.targets + etag = 87357cb36379ac589c3981bddec4c5f7f89c55356573bd203acbea4b66fe3427 + weak +[file "src/kzu.snk"] + url = https://github.com/kzu/oss/blob/main/src/kzu.snk + etag = b8d789b5b6bea017cdcc8badcea888ad78de3e34298efca922054e9fb0e7b6b9 + weak diff --git a/Directory.Build.rsp b/Directory.Build.rsp new file mode 100644 index 00000000..7c0dbc1e --- /dev/null +++ b/Directory.Build.rsp @@ -0,0 +1,5 @@ +# See https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-response-files +-nr:false +-m:1 +-v:m +-clp:Summary;ForceNoAlign \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 0bdc1962..00000000 --- a/LICENSE +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (c) .NET Foundation. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -these files except in compliance with the License. You may obtain a copy of the -License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed -under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. diff --git a/NuGetizer.sln b/NuGetizer.sln index 21643065..f09cfe35 100644 --- a/NuGetizer.sln +++ b/NuGetizer.sln @@ -6,10 +6,8 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CDF1828A-0877-4238-A218-5E4FE219F6CC}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig - src\Directory.Build.props = src\Directory.Build.props - src\Directory.Build.targets = src\Directory.Build.targets - src\NuGet.Config = src\NuGet.Config - README.md = README.md + src\Directory.props = src\Directory.props + src\Directory.targets = src\Directory.targets EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NuGetizer.Tasks", "src\NuGetizer.Tasks\NuGetizer.Tasks.csproj", "{57F59BF6-9272-4B66-98A1-334B3FDA5721}" @@ -23,9 +21,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-nugetize", "src\dotn EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{AFDBEE29-AF6A-4BC2-8960-DAFD2B2C2D2A}" ProjectSection(SolutionItems) = preProject - azure-pipelines.yml = azure-pipelines.yml .github\workflows\build.yml = .github\workflows\build.yml .github\workflows\release.yml = .github\workflows\release.yml + .github\workflows\tag.yml = .github\workflows\tag.yml EndProjectSection EndProject Global diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 4c1b38aa..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,39 +0,0 @@ -pool: - vmImage: 'windows-2019' - -variables: - - name: DOTNET_NOLOGO - value: 'true' - -steps: -- checkout: self - -- task: UseDotNet@2 - inputs: - packageType: sdk - version: 5.0.100-rc.1.20452.10 - performMultiLevelLookup: true - -- task: UseDotNet@2 - inputs: - packageType: sdk - version: 3.1.x - performMultiLevelLookup: true - -- script: dotnet tool update -g dotnet-vs - displayName: dotnet tool update -g dotnet-vs -- pwsh: echo "##vso[task.setvariable variable=MSB]$(vs where preview --prop=InstallationPath)" -- script: vs install preview --quiet +Microsoft.VisualStudio.Component.ManagedDesktop.Core +Microsoft.NetCore.Component.DevelopmentTools - displayName: vs install preview - condition: eq(variables['MSB'], '') -- pwsh: echo "##vso[task.prependpath]$(vs where preview --prop=InstallationPath)\MSBuild\Current\Bin" - displayName: prepend MSBuild to %PATH% -- script: msbuild -r -bl:$(System.DefaultWorkingDirectory)/logs/build.binlog - displayName: msbuild -r -- script: msbuild -t:test - displayName: msbuild -t:test -- publish: $(System.DefaultWorkingDirectory)/logs - artifact: logs - condition: always() -- script: msbuild -t:Pack -p:PackOnBuild=true - displayName: msbuild -t:pack \ No newline at end of file diff --git a/code-of-conduct.md b/code-of-conduct.md new file mode 100644 index 00000000..775f221c --- /dev/null +++ b/code-of-conduct.md @@ -0,0 +1,6 @@ +# Code of Conduct + +This project has adopted the code of conduct defined by the Contributor Covenant +to clarify expected behavior in our community. + +For more information, see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct). diff --git a/license.txt b/license.txt new file mode 100644 index 00000000..83969dca --- /dev/null +++ b/license.txt @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) Daniel Cazzulino and Contributors + +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/README.md b/readme.md similarity index 100% rename from README.md rename to readme.md diff --git a/security.md b/security.md new file mode 100644 index 00000000..a17430a3 --- /dev/null +++ b/security.md @@ -0,0 +1,9 @@ +# Security Policy + +## Reporting a Vulnerability + +Security issues and bugs should be reported privately by emailing hello@clarius.org. +You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your +original message and ping [@kzu](https://twitter.com/kzu) on Twitter. + +Please do not open issues for anything you think might have a security implication. \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props index c68af944..aade2e19 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,54 +1,128 @@ + - + kzu - NuGetizer - Copyright (C) Daniel Cazzulino $([System.DateTime]::Now.Year). All rights reserved. - + Copyright (C) Daniel Cazzulino and Contributors. All rights reserved. false - Apache-2.0 - - 42.42.42 + MIT + icon.png true true - $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\bin')) + $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\bin')) + + + true + + https://pkg.kzu.io/index.json;https://api.nuget.org/v3/index.json;$(RestoreSources) + + + + + + - true + + Latest + + + false + embedded true - Preview + enable + + + $(MSBuildProjectName) + $(MSBuildProjectName.IndexOf('.')) + $(MSBuildProjectName.Substring(0, $(RootNamespaceDot))) + + + $(DefaultItemExcludes);*.binlog;*.zip;*.rsp;*.items;**/TestResults/**/*.* + + + $(MSBuildThisFileDirectory)kzu.snk + + 002400000480000094000000060200000024000052534131000400000100010051155fd0ee280be78d81cc979423f1129ec5dd28edce9cd94fd679890639cad54c121ebdb606f8659659cd313d3b3db7fa41e2271158dd602bb0039a142717117fa1f63d93a2d288a1c2f920ec05c4858d344a45d48ebd31c1368ab783596b382b611d8c92f9c1b3d338296aa21b12f3bc9f34de87756100c172c52a24bad2db + 00352124762f2aa5 + true + + true + true true + true - false - $(DefaultItemExcludes);*.binlog;*.zip;*.rsp;nugetize.* + + true false + - - true - true + + + 42.42.42 + + + + <_VersionLabel>$(VersionLabel.Replace('refs/heads/', '')) + + <_VersionLabel Condition="$(_VersionLabel.Contains('refs/pull/'))">$(VersionLabel.TrimEnd('.0123456789')) + + <_VersionLabel>$(_VersionLabel.Replace('refs/pull/', 'pr')) + + <_VersionLabel>$(_VersionLabel.Replace('/merge', '')) + + <_VersionLabel>$(_VersionLabel.Replace('/', '-')) - - false + + $(_VersionLabel) + + + + + + + + + + false - true + + true - - - - - - - - - - + + + $(CI) + - \ No newline at end of file + + diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 50a6099c..2b376068 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -1,93 +1,146 @@ + - - true - false - + + - false + The Directory.Build.targets are imported after the user's project properties have been + read, and therefore gives us a chance to inspect if an explicit PackageId was provided, + before the NuGet SDK target is imported and defaults it. At this point, we can give + IsPackable a more sensible default, making it false if no PackageId was provided at this + point. --> + false + true - + + + 1.0.0 + $(VersionPrefix)-$(VersionSuffix) + $(VersionPrefix) + - - - $(SourceRevisionId.Substring(0, 9)) - - - - + + + $(PackFolder) + $(PackFolderPath.Replace('\$(TargetFramework)', '')) + $(IntermediateOutputPath)$(PackFolderPath)\ + $(OutputPath)$(PackFolderPath)\ + $(OutputPath) + - $(IntermediateOutputPath)PackFolderKind.g$(DefaultLanguageSourceExtension) + + $(DefineConstants);$(TargetFramework.ToUpperInvariant().TrimEnd('0').TrimEnd('.').Replace('.', '')) - + + + + - - - $(LocalAppData)\NuGet\v3-cache - - $(IsPackable) - - $(UserProfile)\.nuget\packages - - - + + + + - + + + + + + + + + + + + + + + + Condition="'$(SourceControlInformationFeatureSupported)' == 'true' And + '$(IsPackable)' == 'true'"> - - $(Description) + $(Description) - Built from $(RepositoryUrl)/tree/$(SourceRevisionId.Substring(0, 9)) +Built from $(RepositoryUrl)/tree/$(SourceRevisionId.Substring(0, 9)) - - $([System.Text.RegularExpressions.Regex]::Replace('$(RepositoryUrl)', '^(http.*)github\.com/(.+?)/(.*)', '$1$2.github.io/$3')) $(Description) + + + $(PrivateRepositoryUrl) + $(RepositoryUrl) + + $(SourceRevisionId) + $(SourceRevisionId.Substring(0, 9)) - - - <_ExistingPackage Include="$(PackageOutputPath)\$(PackageId)*.nupkg" /> - <_PackageToDelete Include="@(_ExistingPackage)" Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(Filename)', '$(PackageId)\.\d\.\d\.\d.*'))" /> - - - - - - + + - - - - $(NuGetCache)\$(PackageId.ToLowerInvariant()) - + + + + + + + + + + + + + + + + + - - - - + foreach (var item in Items.OrderBy(i => i.ItemSpec)) + { + Log.LogMessage(MessageImportance.High, "{0}: {1}", itemName, item.ItemSpec); + foreach (var name in item.MetadataNames.OfType().OrderBy(_ => _)) + { + try + { + Log.LogMessage(MessageImportance.High, "\t{0}={1}", name, item.GetMetadata(name)); + } + catch { } + } + } + ]]> + + + - \ No newline at end of file + diff --git a/src/Directory.props b/src/Directory.props new file mode 100644 index 00000000..08a6f397 --- /dev/null +++ b/src/Directory.props @@ -0,0 +1,21 @@ + + + + + $(DefaultItemExcludes);nugetize.* + + + false + + disable + false + + $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\ThisAssembly\bin'));$(RestoreSources) + + + + + + + + diff --git a/src/Directory.targets b/src/Directory.targets new file mode 100644 index 00000000..4d2ea22e --- /dev/null +++ b/src/Directory.targets @@ -0,0 +1,20 @@ + + + + + + false + + + + + + $(IntermediateOutputPath)PackFolderKind.g$(DefaultLanguageSourceExtension) + + + + + + + \ No newline at end of file diff --git a/src/NuGet.Config b/src/NuGet.Config deleted file mode 100644 index 1f6c8fc0..00000000 --- a/src/NuGet.Config +++ /dev/null @@ -1,10 +0,0 @@ -๏ปฟ - - - - - - - - - \ No newline at end of file diff --git a/src/NuGetizer.Tasks/AssignPackagePath.cs b/src/NuGetizer.Tasks/AssignPackagePath.cs index 669f2c32..d117bce5 100644 --- a/src/NuGetizer.Tasks/AssignPackagePath.cs +++ b/src/NuGetizer.Tasks/AssignPackagePath.cs @@ -48,7 +48,7 @@ ITaskItem EnsurePackagePath(ITaskItem file, IDictionary kindM { // Switch to full path items var output = new TaskItem( - file.GetBoolean("IsFile", true) && file.ItemSpec.IndexOfAny(Path.GetInvalidPathChars()) == -1 && File.Exists(file.GetMetadata("FullPath")) + file.GetBoolean("IsFile", true) && file.ItemSpec.IndexOfAny(Path.GetInvalidPathChars()) == -1 && File.Exists(file.GetMetadata("FullPath")) ? file.GetMetadata("FullPath") : file.ItemSpec); diff --git a/src/NuGetizer.Tasks/CreatePackage.cs b/src/NuGetizer.Tasks/CreatePackage.cs index 8d222a28..ca4075b0 100644 --- a/src/NuGetizer.Tasks/CreatePackage.cs +++ b/src/NuGetizer.Tasks/CreatePackage.cs @@ -291,7 +291,7 @@ string hash(ITaskItem item) // Support nugetize CLI by ignoring missing files. When creating the final .nupkg, // file existence is checked always already if (!File.Exists(item.GetMetadata("FullPath"))) - return item.GetMetadata("FullPath"); + return item.GetMetadata("FullPath"); using var file = File.OpenRead(item.GetMetadata("FullPath")); return string.Concat(md5.Value.ComputeHash(file).Select(x => x.ToString("x2"))); diff --git a/src/NuGetizer.Tasks/InferImplicitPackageReference.cs b/src/NuGetizer.Tasks/InferImplicitPackageReference.cs index ccad65f8..2a000742 100644 --- a/src/NuGetizer.Tasks/InferImplicitPackageReference.cs +++ b/src/NuGetizer.Tasks/InferImplicitPackageReference.cs @@ -40,7 +40,7 @@ public override bool Execute() { packages.GetOrAdd(parse(parent), _ => new List()) .Add(identity); - } + } else { // In centrally managed package versions, at this point we have diff --git a/src/NuGetizer.Tasks/NuGetizer.Tasks.Pack.targets b/src/NuGetizer.Tasks/NuGetizer.Tasks.Pack.targets new file mode 100644 index 00000000..4abd4ccf --- /dev/null +++ b/src/NuGetizer.Tasks/NuGetizer.Tasks.Pack.targets @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/src/NuGetizer.Tasks/NuGetizer.Tasks.csproj b/src/NuGetizer.Tasks/NuGetizer.Tasks.csproj index dd80582d..971752cb 100644 --- a/src/NuGetizer.Tasks/NuGetizer.Tasks.csproj +++ b/src/NuGetizer.Tasks/NuGetizer.Tasks.csproj @@ -1,8 +1,7 @@ - +๏ปฟ netstandard2.0 - NuGetizer true NuGetizer @@ -12,7 +11,7 @@ - + @@ -24,7 +23,6 @@ - @@ -32,6 +30,7 @@ + \ No newline at end of file diff --git a/src/NuGetizer.Tasks/NuGetizer.Tasks.targets b/src/NuGetizer.Tasks/NuGetizer.Tasks.targets index f3d10297..0c1b4dd9 100644 --- a/src/NuGetizer.Tasks/NuGetizer.Tasks.targets +++ b/src/NuGetizer.Tasks/NuGetizer.Tasks.targets @@ -17,7 +17,6 @@ NuGetizer NuGetizer Simple, flexible and powerful NuGet packaging - icon.png true build diff --git a/src/NuGetizer.Tests/InlineProjectTests.cs b/src/NuGetizer.Tests/InlineProjectTests.cs index 983b43b6..db692341 100644 --- a/src/NuGetizer.Tests/InlineProjectTests.cs +++ b/src/NuGetizer.Tests/InlineProjectTests.cs @@ -452,7 +452,7 @@ public void when_pack_on_build_multitargeting_then_contains_all_targets() ", "Build,GetPackageTargetPath", output); - + result.AssertSuccess(output); Assert.Single(result.Items); @@ -513,15 +513,15 @@ public void when_packing_private_transive_reference_then_packs_lib() result.AssertSuccess(output); // Ref files are not there - Assert.DoesNotContain(result.Items, item + Assert.DoesNotContain(result.Items, item => item.GetMetadata("FullPath").EndsWith(Path.Combine("ref", "netstandard2.0", "System.Runtime.CompilerServices.Unsafe.dll"))); - Assert.DoesNotContain(result.Items, item + Assert.DoesNotContain(result.Items, item => item.GetMetadata("FullPath").EndsWith(Path.Combine("ref", "netstandard2.0", "System.Threading.Tasks.Extensions.dll"))); // Replaced by lib - Assert.Contains(result.Items, item + Assert.Contains(result.Items, item => item.GetMetadata("FullPath").EndsWith(Path.Combine("lib", "netstandard2.0", "System.Runtime.CompilerServices.Unsafe.dll"))); - Assert.Contains(result.Items, item + Assert.Contains(result.Items, item => item.GetMetadata("FullPath").EndsWith(Path.Combine("lib", "netstandard2.0", "System.Threading.Tasks.Extensions.dll"))); } diff --git a/src/NuGetizer.Tests/ModuleInitializer.cs b/src/NuGetizer.Tests/ModuleInitializer.cs index 11b6bff4..f8c6cc6a 100644 --- a/src/NuGetizer.Tests/ModuleInitializer.cs +++ b/src/NuGetizer.Tests/ModuleInitializer.cs @@ -3,15 +3,9 @@ using System.Reflection; using System.Runtime.CompilerServices; -namespace System.Runtime.CompilerServices -{ - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] - public sealed class ModuleInitializerAttribute : Attribute { } -} - namespace NuGetizer.Tests { - internal static class ModuleInitializer + static class ModuleInitializer { static readonly string logFile = Environment.ExpandEnvironmentVariables(@"%TEMP%\NuGetizer.txt"); diff --git a/src/NuGetizer.Tests/ModuleInitializerAttribute.cs b/src/NuGetizer.Tests/ModuleInitializerAttribute.cs new file mode 100644 index 00000000..9f7c2eec --- /dev/null +++ b/src/NuGetizer.Tests/ModuleInitializerAttribute.cs @@ -0,0 +1,5 @@ +๏ปฟnamespace System.Runtime.CompilerServices +{ + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + public sealed class ModuleInitializerAttribute : Attribute { } +} diff --git a/src/NuGetizer.Tests/NuGetizer.Tests.csproj b/src/NuGetizer.Tests/NuGetizer.Tests.csproj index cb92d1b9..ebc0fb9a 100644 --- a/src/NuGetizer.Tests/NuGetizer.Tests.csproj +++ b/src/NuGetizer.Tests/NuGetizer.Tests.csproj @@ -3,16 +3,10 @@ net472 $(DefaultItemExcludes);Scenarios\**\* - Preview - true - true - - - ..\NuGetizer.Tasks\bin\$(Configuration)\NuGetizer.Tasks.dll - + @@ -30,12 +24,14 @@ - + + + diff --git a/src/NuGetizer.Tests/given_a_library.cs b/src/NuGetizer.Tests/given_a_library.cs index 2eef3dc1..a0a7099c 100644 --- a/src/NuGetizer.Tests/given_a_library.cs +++ b/src/NuGetizer.Tests/given_a_library.cs @@ -1,7 +1,4 @@ -๏ปฟusing System.IO; -using System.Linq; -using System.ServiceModel.Configuration; -using Microsoft.Build.Execution; +๏ปฟusing System.Linq; using Xunit; using Xunit.Abstractions; @@ -22,8 +19,8 @@ public given_a_library(ITestOutputHelper output) [Fact] public void when_pack_compile_then_excludes_generated_files() { - var result = Builder.BuildScenario(nameof(given_a_library), - new { PackCompile = "true" }, + var result = Builder.BuildScenario(nameof(given_a_library), + new { PackCompile = "true" }, target: "Build,GetPackageContents,Pack"); Assert.True(result.BuildResult.HasResultsForTarget("GetPackageContents")); diff --git a/src/NuGetizer.Tests/given_a_notargets_sdk_project.cs b/src/NuGetizer.Tests/given_a_notargets_sdk_project.cs index 37921b0c..755e3300 100644 --- a/src/NuGetizer.Tests/given_a_notargets_sdk_project.cs +++ b/src/NuGetizer.Tests/given_a_notargets_sdk_project.cs @@ -24,7 +24,7 @@ public void cam_reference_packaging_project() -"), +"), ("other.msbuildproj", @" diff --git a/src/NuGetizer.Tests/given_projectreferences.cs b/src/NuGetizer.Tests/given_projectreferences.cs index 4526bb3f..95abb7c4 100644 --- a/src/NuGetizer.Tests/given_projectreferences.cs +++ b/src/NuGetizer.Tests/given_projectreferences.cs @@ -24,7 +24,7 @@ public void when_privateassets_all_then_packs_library() ", - "GetPackageContents", output, + "GetPackageContents", output, files: ("Library.csproj", @" diff --git a/src/dotnet-nugetize/Program.cs b/src/dotnet-nugetize/Program.cs index 4bfa4610..f2053cd9 100644 --- a/src/dotnet-nugetize/Program.cs +++ b/src/dotnet-nugetize/Program.cs @@ -135,7 +135,7 @@ int Execute() if (contentsOnly) { ColorConsole.WriteLine($"Project {project} is not packable, rendering its contributed package contents.".Yellow()); - + var dependencies = doc.Root.Descendants("PackageContent") .Where(x => "Dependency".Equals(x.Element("PackFolder")?.Value, StringComparison.OrdinalIgnoreCase)) diff --git a/src/icon.png b/src/icon.png new file mode 100644 index 00000000..4b2c74c2 Binary files /dev/null and b/src/icon.png differ diff --git a/src/kzu.snk b/src/kzu.snk new file mode 100644 index 00000000..8e181aea Binary files /dev/null and b/src/kzu.snk differ