Skip to content

Commit 09d9999

Browse files
committed
Fix bugs, fix nuget packaging, adjust readme
1 parent 2f03ff0 commit 09d9999

19 files changed

Lines changed: 223 additions & 166 deletions

.editorconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ indent_style = space
1111
end_of_line = lf
1212
insert_final_newline = true
1313
tab_width = 4
14-
spelling_languages = en-us
15-
spelling_exclusion_path = .\spelling_exclusion.dic
16-
spelling_use_default_exclusion_dictionary = true
1714

1815
[*.json]
1916
indent_size = 2

PackScan.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1717
LICENSE = LICENSE
1818
nuget.config = nuget.config
1919
ReadMe.md = ReadMe.md
20-
spelling_exclusion.dic = spelling_exclusion.dic
2120
EndProjectSection
2221
EndProject
2322
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".config", ".config", "{C20C1112-EF7A-48C1-9282-872163BBDFC4}"

ReadMe.md

Lines changed: 59 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,57 +12,72 @@ The included analyzer helps you ensure license compliance by identifying package
1212
Additionally, these tools offer optional configurations to generate code that provides access to icons, license texts, ReadMe content, release notes, and other package information.
1313
You can include these additional resources based on your specific needs.
1414

15-
Key Features:
16-
* Generate code for easy access to package data
17-
* Analyze and enforce license compliance
18-
* Customizable configuration settings
19-
* Seamless integration with your projects
20-
* Possibility of use with CI/CD
15+
Currently, the project only supports C#, but it is designed in a way that allows for future support of VB.NET or F#.
2116

22-
You have two options to choose from:
17+
### Key Features
2318

24-
**[PackScan.Tool](https://www.nuget.org/packages/PackScan.Tool)**
19+
1. **Generate Package Data:**</br>
20+
Generate simple and easily accessible code to retrieve detailed information about the packages installed in your project.
21+
With this code, you can easily access package versions, dependencies, licenses, and other data.
22+
23+
3. **Check License Compliance:**</br>
24+
The included analyzer helps you ensure compliance with licensing requirements.
25+
Identify packages that contain licenses not compatible with your project or company policies, enabling you to address potential licensing issues early on.
26+
27+
5. **Customizable Configuration:**</br>
28+
Tailor the behavior of the tool to perfectly match your requirements.
29+
Adjust the configuration to change how package contents are loaded, code is generated, and license analyses are performed.
30+
31+
7. **Seamless Project Integration:**</br>
32+
The project can be seamlessly integrated into your existing projects.
33+
Install the required NuGet packages and configure the settings accordingly. Accessing package data and license information is straightforward through the generated code.
34+
35+
9. **Possible Use with CI/CD:**</br>
36+
The .NET Tool allows integration into CI/CD processes, automating package analysis and management in your continuous integration and deployment workflows.
37+
38+
### **[PackScan.Tool](https://www.nuget.org/packages/PackScan.Tool)**
2539

2640
The .NET Tool provides integration into CI/CD processes and supports different ways of depositing content files.
2741

28-
**[PackScan.Analyzer](https://www.nuget.org/packages/PackScan.Analyzer)**
42+
### **[PackScan.Analyzer](https://www.nuget.org/packages/PackScan.Analyzer)**
2943

3044
The Analyzer can be configured directly in your project and supports checking which packages and licenses are allowed.
3145

3246
# Installation
3347

34-
For both options, you need to install the NuGet package [PackScan.PackagesProvider.Abstractions](https://www.nuget.org/packages/PackScan.PackagesProvider.Abstractions) in those projects in which you want to use the generated code.</br>
35-
You can install it using the NuGet package manager or add the following lines to your project:
48+
### Analyzer
49+
50+
Install the analyzer:
3651

3752
```
38-
<ItemGroup>
39-
<PackageReference Include="PackScan.PackagesProvider.Abstractions" Version="x.x.x" /> <!-- use the latest version -->
40-
</ItemGroup>
53+
dotnet add package --prerelease PackScan.Analyzer
4154
```
4255

43-
## .NET Tool
56+
Additionally, you need to install the following package in all projects where you want to use the code:
57+
58+
```
59+
dotnet add package --prerelease PackScan.PackagesProvider.Abstractions
60+
```
4461

45-
To install the .NET Tool, run [dotnet tool install](https://learn.microsoft.com/de-de/dotnet/core/tools/dotnet-tool-install) with "PackScan.Tool".
62+
### .NET Tool
4663

47-
It is also recommended to install the following package to have all the standard configurations:
64+
Install the .NET Tool:
4865

4966
```
50-
<ItemGroup>
51-
<PackageReference Include="PackScan.Defaults" Version="x.x.x" /> <!-- use the latest version -->
52-
</ItemGroup>
67+
dotnet tool install --prerelease --global PackScan.Tool
5368
```
5469

55-
## Analyzer
56-
57-
To install the analyzer, use the NuGet package manager or add the following lines to your project:
70+
It is also necessary to install the following package to enable all configuration features:
5871

5972
```
60-
<ItemGroup>
61-
<PackageReference Include="PackScan.Analyzer" Version="x.x.x" /> <!-- use the latest version -->
62-
</ItemGroup>
73+
dotnet add package --prerelease PackScan.Defaults
6374
```
6475

65-
Both options offer similar benefits and can be selected and configured based on your specific needs and requirements.
76+
Additionally, you need to install the following package in all projects where you want to use the code:
77+
78+
```
79+
dotnet add package --prerelease PackScan.PackagesProvider.Abstractions
80+
```
6681

6782
# Generated Result
6883

@@ -75,7 +90,9 @@ Here's how you can use the generated code:
7590
var serilog = Packages.GetPackageById("Serilog");
7691

7792
foreach (var package in Packages.GetPackages())
93+
{
7894
Console.WriteLine($"{package.Id} | {package.Version.Value} | {package.License?.Expression}");
95+
}
7996

8097
// or with an instance
8198
@@ -84,7 +101,9 @@ IPackagesProvider instance = new Packages();
84101
var serilog = instance.GetPackageById("Serilog");
85102

86103
foreach (var package in instance.GetPackages())
104+
{
87105
Console.WriteLine($"{package.Id} | {package.Version.Value} | {package.License?.Expression}");
106+
}
88107

89108
// or with dependency injection
90109
@@ -96,7 +115,9 @@ var packagesProvider = services.GetRequiredService<IPackagesProvider>();
96115
var serilog = instance.GetPackageById("Serilog");
97116

98117
foreach (var package in instance.GetPackages())
118+
{
99119
Console.WriteLine($"{package.Id} | {package.Version.Value} | {package.License?.Expression}");
120+
}
100121

101122
```
102123

@@ -141,26 +162,6 @@ dotnet package-tools generate-packages-provider --output PackagesProvider --load
141162

142163
### Project Properties
143164

144-
- **IncludeWellKnownPackageIds**</br>
145-
Specifies whether to include the default set of KnownPackageId entries (`true`) or not (`false`).</br>
146-
Default value: `true`</br>
147-
Well-known package id values:
148-
- **System** | Owner: Microsoft, Product: .NET
149-
- **runtime** | Owner: Microsoft, Product: .NET Runtime
150-
- **NETStandard** | Owner: Microsoft, Product: .NET Standard
151-
- **Microsoft** | Owner: Microsoft
152-
- **Microsoft.Maui** | Owner: Microsoft, Product: MAUI
153-
- **Microsoft.Azure** | Owner: Microsoft, Product: Azure
154-
- **Microsoft.AspNetCore** | Owner: Microsoft, Product: ASP.NET Core
155-
- **Microsoft.EntityFrameworkCore** | Owner: Microsoft, Product: Entity Framework
156-
157-
- **IncludeWellKnownAllowedLicenses**</br>
158-
Specifies whether to include the default set of allowed licenses by expression or owner (`true`) or not (`false`).</br>
159-
Default value: `true`</br>
160-
Well-known licenses:
161-
- By expression: MIT
162-
- By owner: Microsoft
163-
164165
- **AllowedLicensesAnalyzationEnabled**</br>
165166
Determines whether to check the licenses of the installed packages (`true`) or not (`false`).</br>
166167
This option should be preferred over disabling all warnings since it does not require package data to be loaded.</br>
@@ -226,13 +227,24 @@ A list of all allowed licenses or license expressions.</br>
226227
- **AllowedLicenseByOwner**</br>
227228
A list of all explicitly allowed package owners to be excluded from the license check.</br>
228229
Please note that you need to map the owners manually as they cannot be automatically extracted.</br>
230+
Default values: `Microsoft`
229231

230232
- **AllowedLicenseByPackage**</br>
231233
A list of all explicitly allowed packages to be excluded from the license check.</br>
234+
Default values: `MIT` `Apache-2.0`
232235

233236
- **KnownPackageId**</br>
234237
Allows registering known package ID prefixes along with their corresponding owners and products.
235238
For each package, the last matching prefix is used to determine the associated data.</br>
239+
Default values: </br>
240+
- **System** | Owner: Microsoft, Product: .NET
241+
- **runtime** | Owner: Microsoft, Product: .NET Runtime
242+
- **NETStandard** | Owner: Microsoft, Product: .NET Standard
243+
- **Microsoft** | Owner: Microsoft
244+
- **Microsoft.Maui** | Owner: Microsoft, Product: MAUI
245+
- **Microsoft.Azure** | Owner: Microsoft, Product: Azure
246+
- **Microsoft.AspNetCore** | Owner: Microsoft, Product: ASP.NET Core
247+
- **Microsoft.EntityFrameworkCore** | Owner: Microsoft, Product: Entity Framework
236248

237249
## .NET Tool
238250

spelling_exclusion.dic

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/NuGet.Metadata.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<PropertyGroup>
8-
<Version>0.1.0</Version>
8+
<Version>0.1.0-alpha</Version>
99
<Authors>Loop8ack</Authors>
1010
<PackageReadmeFile>ReadMe.md</PackageReadmeFile>
1111
<PackageLicenseExpression>MIT</PackageLicenseExpression>
@@ -15,12 +15,12 @@
1515
<PackageTags>msbuild;package;generator</PackageTags>
1616
<NeutralLanguage>en</NeutralLanguage>
1717
<Copyright>Copyright $([System.DateTime]::Now.ToString(yyyy)) $(Authors)</Copyright>
18-
<Description>Simplify package information retrieval and license compliance in your .NET projects. Access comprehensive package details, including dependencies, icons, license texts, ReadMe content, and release notes directly from your code.</Description>
18+
<Description>Simplify package information retrieval and license compliance in your .NET projects. Access comprehensive package details, including dependencies, icons, license texts, ReadMe content, release notes and more directly from your code.</Description>
1919
</PropertyGroup>
2020

2121
<ItemGroup>
22-
<Content Include="$(MSBuildThisFileDirectory)\..\LICENSE" PackagePath="\" InProject="false" Visible="false" Pack="true" />
23-
<Content Include="$(MSBuildThisFileDirectory)\..\ReadMe.md" PackagePath="\" InProject="false" Visible="false" Pack="true" />
22+
<Content Include="$(MSBuildThisFileDirectory)\..\LICENSE" PackagePath="\" Visible="false" Pack="true" />
23+
<Content Include="$(MSBuildThisFileDirectory)\..\ReadMe.md" PackagePath="\" Visible="false" Pack="true" />
2424
</ItemGroup>
2525

2626
</Project>

src/PackScan.Analyzer/Core/Diagnostics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public static class EmptyLicenseIsNotAllowed
151151
= new DiagnosticDescriptor(
152152
id: $"{Prefix}{(int)Id.EmptyLicenseIsNotAllowed:000}",
153153
title: "Packages without a license are not allowed",
154-
messageFormat: "Empty licenses are not allowed. Possibly the license could not be read. Consider allowing the package directly (AllowedLicenseByPackage) or empty licenses (AllowEmptyLicense). Affected packages: {0}",
154+
messageFormat: "Empty licenses are not allowed. Possibly the license could not be read. Consider allowing the package directly (AllowedLicenseByPackage) or empty licenses (AllowEmptyLicenses). Affected packages: {0}",
155155
category: Category,
156156
DiagnosticSeverity.Warning,
157157
isEnabledByDefault: true);

src/PackScan.Analyzer/Core/Options/KnownOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ internal static class KnownOptions
99
private static readonly IReadOnlyDictionary<string, Language> _languageValueMapping =
1010
new Dictionary<string, Language>(StringComparer.OrdinalIgnoreCase)
1111
{
12-
["C#"] = Language.CSharp,
13-
["F#"] = Language.FSharp,
12+
["C"] = Language.CSharp,
13+
["F"] = Language.FSharp,
1414
["VB"] = Language.VisualBasic,
1515
};
1616

src/PackScan.Analyzer/Core/Services/PackageDataReaderService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ public IReadOnlyCollection<IPackageData> Read()
4545

4646
IEnumerable<KnownPackageId> knownPackageIds = ParseKnownPackageIds(KnownPackageIds.Value).ToArray();
4747

48-
IPackageDataReader reader = new PackageDataReader(assetsFilePath, TargetFramework, RuntimeIdentifier, knownPackageIds);
48+
IPackageDataReader reader = new PackageDataReader(assetsFilePath, TargetFramework, RuntimeIdentifier)
49+
{
50+
KnownPackageIds = ParseKnownPackageIds(KnownPackageIds.Value).ToArray()
51+
};
4952

5053
return reader.Read();
5154
}

src/PackScan.Analyzer/PackScan.Analyzer.csproj

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@
66
<TargetFramework>netstandard2.0</TargetFramework>
77
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
88
<BuildOutputTargetFolder>analyzers/dotnet/cs</BuildOutputTargetFolder>
9-
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
109
<DevelopmentDependency>true</DevelopmentDependency>
1110
<IsRoslynComponent>true</IsRoslynComponent>
11+
<NoWarn>$(NoWarn);NU5128</NoWarn>
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15+
<Content Include="PackScan.Analyzer.props" PackagePath="build\$(PackageId).props" />
1516
<Content Include="PackScan.Analyzer.targets" PackagePath="build\$(PackageId).targets" />
17+
18+
<Content Include="..\PackScan.Defaults\PackScan.Defaults.props" PackagePath="build\%(Filename)%(Extension)" Visible="False" Pack="true" />
19+
<Content Include="..\PackScan.Defaults\PackScan.Defaults.targets" PackagePath="build\%(Filename)%(Extension)" Visible="False" Pack="true" />
1620
</ItemGroup>
1721

1822
<ItemGroup>
19-
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
23+
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" PrivateAssets="all" />
2024
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
2125
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" PrivateAssets="all" />
2226
<PackageReference Include="IsExternalInit" Version="1.0.3" PrivateAssets="all" />
@@ -25,9 +29,9 @@
2529
</ItemGroup>
2630

2731
<ItemGroup>
28-
<ProjectReference Include="..\PackScan.PackagesProvider.Abstractions\PackScan.PackagesProvider.Abstractions.csproj" />
29-
<ProjectReference Include="..\PackScan.PackagesProvider.Generator\PackScan.PackagesProvider.Generator.csproj" />
30-
<ProjectReference Include="..\PackScan.PackagesReader\PackScan.PackagesReader.csproj" />
32+
<ProjectReference Include="..\PackScan.PackagesProvider.Abstractions\PackScan.PackagesProvider.Abstractions.csproj" PrivateAssets="all" />
33+
<ProjectReference Include="..\PackScan.PackagesProvider.Generator\PackScan.PackagesProvider.Generator.csproj" PrivateAssets="all" />
34+
<ProjectReference Include="..\PackScan.PackagesReader\PackScan.PackagesReader.csproj" PrivateAssets="all" />
3135
</ItemGroup>
3236

3337
<!-- Embed referenced dlls so that they can be loaded at runtime -->
@@ -63,5 +67,5 @@
6367
</EmbeddedResource>
6468
</ItemGroup>
6569
</Target>
66-
70+
6771
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project>
2+
3+
<Import Project="$(MSBuildThisFileDirectory)\PackScan.Defaults.props"
4+
Condition="Exists('$(MSBuildThisFileDirectory)\PackScan.Defaults.props')"/>
5+
6+
</Project>

0 commit comments

Comments
 (0)