diff --git a/LuYao.ResourcePacker.MSBuild/ResourcePackerTask.cs b/LuYao.ResourcePacker.MSBuild/ResourcePackerTask.cs index b09f3ae..9d03c77 100644 --- a/LuYao.ResourcePacker.MSBuild/ResourcePackerTask.cs +++ b/LuYao.ResourcePacker.MSBuild/ResourcePackerTask.cs @@ -16,7 +16,7 @@ public class ResourcePackerTask : Task [Required] public string AssemblyName { get; set; } - public string ResourceDirectory { get; set; } = "Resources"; + public string ResourceDirectory { get; set; } = "Attachments"; public string OutputFileName { get; set; } diff --git a/LuYao.ResourcePacker.MSBuild/build/LuYao.ResourcePacker.MSBuild.props b/LuYao.ResourcePacker.MSBuild/build/LuYao.ResourcePacker.MSBuild.props index de588e6..86e4f78 100644 --- a/LuYao.ResourcePacker.MSBuild/build/LuYao.ResourcePacker.MSBuild.props +++ b/LuYao.ResourcePacker.MSBuild/build/LuYao.ResourcePacker.MSBuild.props @@ -2,7 +2,7 @@ true - Resources + Attachments diff --git a/LuYao.ResourcePacker.SourceGenerator/ResourcePackageGenerator.cs b/LuYao.ResourcePacker.SourceGenerator/ResourcePackageGenerator.cs index 6e977a8..5cc4d2e 100644 --- a/LuYao.ResourcePacker.SourceGenerator/ResourcePackageGenerator.cs +++ b/LuYao.ResourcePacker.SourceGenerator/ResourcePackageGenerator.cs @@ -39,7 +39,7 @@ private static void Execute(SourceProductionContext context, Compilation compila System.Collections.Immutable.ImmutableArray resourceFiles, AnalyzerConfigOptionsProvider configOptions) { - // Get the resource directory from analyzer config (default to "Resources") + // Get the resource directory from analyzer config (default to "Attachments") var resourceDirectory = GetResourceDirectory(configOptions); // Filter additional files to only include those in the resource directory @@ -108,8 +108,8 @@ private static string GetResourceDirectory(AnalyzerConfigOptionsProvider configO } } - // Default to "Resources" - return "Resources"; + // Default to "Attachments" + return "Attachments"; } private static bool IsInResourceDirectory(string filePath, string resourceDirectory) @@ -124,7 +124,7 @@ private static bool IsInResourceDirectory(string filePath, string resourceDirect var normalizedDir = resourceDirectory.Replace('\\', '/'); // Check if the file path contains the resource directory - // Handle both "Resources" and "Resources/" formats + // Handle both with and without trailing slash (e.g., "Attachments" and "Attachments/") return normalizedPath.Contains($"/{normalizedDir}/") || normalizedPath.EndsWith($"/{normalizedDir}"); } diff --git a/README.md b/README.md index dcb33d9..e150e99 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ LuYao.ResourcePacker is a .NET library for packaging and accessing resource file - Pack multiple resource files into a single .dat file during build - **Intelligent tiered compression with GZip** - automatic compression with sampling for optimal space/performance -- Directory-based resource scanning (default: Resources directory) +- Directory-based resource scanning (default: Attachments directory) - MSBuild integration - Simple runtime API for resource access - Async support @@ -35,9 +35,9 @@ dotnet add package LuYao.ResourcePacker ### 1. Basic Setup -Place your resource files in the `Resources` directory: +Place your resource files in the `Attachments` directory: ``` -Resources/ +Attachments/ ├── message.json ├── config.txt └── template.html @@ -45,6 +45,8 @@ Resources/ The resources will be automatically packed into a .dat file during build. +> **Note**: The default directory was changed from `Resources` to `Attachments` to avoid conflicts with C# .resx files, which typically use the `Resources` directory. If you prefer to use `Resources` or any other directory name, you can configure it in your .csproj file (see Configuration section below). + ### 2. Runtime Access - Original API Access resources at runtime using the `ResourcePackageReader`: @@ -106,8 +108,8 @@ In your .csproj file: true - - Resources + + Attachments $(AssemblyName).dat diff --git a/examples/ExampleProject/Resources/config.json b/examples/ExampleProject/Attachments/config.json similarity index 100% rename from examples/ExampleProject/Resources/config.json rename to examples/ExampleProject/Attachments/config.json diff --git a/examples/ExampleProject/Resources/message.json b/examples/ExampleProject/Attachments/message.json similarity index 100% rename from examples/ExampleProject/Resources/message.json rename to examples/ExampleProject/Attachments/message.json diff --git a/examples/ExampleProject/Resources/template.html b/examples/ExampleProject/Attachments/template.html similarity index 100% rename from examples/ExampleProject/Resources/template.html rename to examples/ExampleProject/Attachments/template.html diff --git a/examples/ExampleProject/ExampleProject.csproj b/examples/ExampleProject/ExampleProject.csproj index 844c60e..97c8b94 100644 --- a/examples/ExampleProject/ExampleProject.csproj +++ b/examples/ExampleProject/ExampleProject.csproj @@ -6,7 +6,7 @@ enable enable true - Resources + Attachments $(AssemblyName).dat false @@ -20,7 +20,7 @@ - + - + diff --git a/examples/ExampleProject/README.md b/examples/ExampleProject/README.md index 0589b01..399d5e3 100644 --- a/examples/ExampleProject/README.md +++ b/examples/ExampleProject/README.md @@ -6,7 +6,7 @@ This is a console application demonstrating how to use the LuYao.ResourcePacker ## What This Example Demonstrates -1. **Resource File Setup**: Place resource files in a `Resources` folder with the `.res.` pattern in the filename (e.g., `message.res.json`, `config.res.json`, `template.res.html`) +1. **Resource File Setup**: Place resource files in an `Attachments` folder (e.g., `message.json`, `config.json`, `template.html`) 2. **Automatic Build-Time Packing**: During build, all `.res.*` files are automatically packed into a single `.dat` file @@ -18,10 +18,10 @@ This is a console application demonstrating how to use the LuYao.ResourcePacker ExampleProject/ ├── ExampleProject.csproj # Project configuration with ResourcePacker integration ├── Program.cs # Main application demonstrating resource access -├── Resources/ # Directory containing resource files -│ ├── message.res.json # JSON resource with greeting and features -│ ├── config.res.json # JSON resource with configuration -│ └── template.res.html # HTML template resource +├── Attachments/ # Directory containing resource files +│ ├── message.json # JSON resource with greeting and features +│ ├── config.json # JSON resource with configuration +│ └── template.html # HTML template resource └── README.md # This file ``` @@ -44,8 +44,8 @@ ExampleProject/ ## What Happens During Build -1. The MSBuild integration scans for files matching the pattern `*.res.*` -2. All matching files are packed into `ExampleProject.dat` +1. The MSBuild integration scans for files in the `Attachments` directory +2. All files are packed into `ExampleProject.dat` 3. The `.dat` file is copied to the output directory 4. At runtime, the application reads resources from the `.dat` file @@ -101,7 +101,7 @@ If you're creating your own project using LuYao.ResourcePacker, follow these ste dotnet add package LuYao.ResourcePacker ``` -2. Add resource files with the `.res.` pattern to your project +2. Add resource files to the `Attachments` directory in your project 3. The MSBuild integration will automatically pack your resources during build @@ -119,7 +119,7 @@ The example project uses the following MSBuild properties in `ExampleProject.csp ``` You can also customize: -- `ResourcePackerPattern` - Custom file pattern (default: `*.res.*`) +- `ResourcePackerDirectory` - Custom resource directory (default: `Attachments`) - `ResourcePackerOutputFileName` - Custom output filename (default: `$(AssemblyName).dat`) ## Learn More diff --git a/examples/Lib1.Ns2.Ns3/Resources/test.txt b/examples/Lib1.Ns2.Ns3/Attachments/test.txt similarity index 100% rename from examples/Lib1.Ns2.Ns3/Resources/test.txt rename to examples/Lib1.Ns2.Ns3/Attachments/test.txt diff --git a/examples/Lib1.Ns2.Ns3/Lib1.Ns2.Ns3.csproj b/examples/Lib1.Ns2.Ns3/Lib1.Ns2.Ns3.csproj index 0a6e300..6b090ad 100644 --- a/examples/Lib1.Ns2.Ns3/Lib1.Ns2.Ns3.csproj +++ b/examples/Lib1.Ns2.Ns3/Lib1.Ns2.Ns3.csproj @@ -6,7 +6,7 @@ enable false true - Resources + Attachments @@ -18,12 +18,12 @@ - + - + diff --git a/examples/Lib1/Resources/test.txt b/examples/Lib1/Attachments/test.txt similarity index 100% rename from examples/Lib1/Resources/test.txt rename to examples/Lib1/Attachments/test.txt diff --git a/examples/Lib1/Lib1.csproj b/examples/Lib1/Lib1.csproj index db6ffd0..04ca9e9 100644 --- a/examples/Lib1/Lib1.csproj +++ b/examples/Lib1/Lib1.csproj @@ -6,7 +6,7 @@ enable false true - Resources + Attachments @@ -18,12 +18,12 @@ - + - + diff --git a/examples/Lib2/Resources/test.txt b/examples/Lib2/Attachments/test.txt similarity index 100% rename from examples/Lib2/Resources/test.txt rename to examples/Lib2/Attachments/test.txt diff --git a/examples/Lib2/Lib2.csproj b/examples/Lib2/Lib2.csproj index 6610d37..8ccbcb7 100644 --- a/examples/Lib2/Lib2.csproj +++ b/examples/Lib2/Lib2.csproj @@ -6,7 +6,7 @@ enable false true - Resources + Attachments @@ -19,12 +19,12 @@ - + - + enable false true - Resources + Attachments @@ -19,12 +19,12 @@ - + - + enable enable true - Resources + Attachments $(AssemblyName).dat false @@ -20,7 +20,7 @@ - + - + diff --git a/examples/NuGetReferenceExample/README.md b/examples/NuGetReferenceExample/README.md index 302ebe7..27e4577 100644 --- a/examples/NuGetReferenceExample/README.md +++ b/examples/NuGetReferenceExample/README.md @@ -15,9 +15,8 @@ Alternatively, use the published NuGet package version once available. NuGetReferenceExample/ ├── NuGetReferenceExample.csproj # Project file with NuGet package reference ├── Program.cs # Application code -├── Resources/ -│ ├── config.res.json # Resource file (JSON) -│ └── message.res.txt # Resource file (text) +├── Attachments/ +│ └── config.json # Resource file (JSON) └── README.md ``` @@ -29,11 +28,11 @@ NuGetReferenceExample/ 2. **Automatic Build Integration**: The MSBuild targets and props files are automatically imported by NuGet, so you don't need to manually configure any build tasks. -3. **Resource Naming Convention**: Files matching the pattern `*.res.*` are automatically packed into a `.dat` file during build. +3. **Resource Directory**: Files in the `Attachments` directory are automatically packed into a `.dat` file during build. 4. **Configuration**: You can customize the behavior using MSBuild properties: - `ResourcePackerEnabled`: Enable/disable resource packing (default: `true`) - - `ResourcePackerPattern`: File pattern for resources (default: `*.res.*`) + - `ResourcePackerDirectory`: Resource directory name (default: `Attachments`) - `ResourcePackerOutputFileName`: Output filename (default: `$(AssemblyName).dat`) ## Building (with local NuGet package) diff --git a/examples/RootNamespaceTest/Resources/config.json b/examples/RootNamespaceTest/Attachments/config.json similarity index 100% rename from examples/RootNamespaceTest/Resources/config.json rename to examples/RootNamespaceTest/Attachments/config.json diff --git a/examples/RootNamespaceTest/Resources/sample.txt b/examples/RootNamespaceTest/Attachments/sample.txt similarity index 100% rename from examples/RootNamespaceTest/Resources/sample.txt rename to examples/RootNamespaceTest/Attachments/sample.txt diff --git a/examples/RootNamespaceTest/README.md b/examples/RootNamespaceTest/README.md index 3b5bb6b..866f8be 100644 --- a/examples/RootNamespaceTest/README.md +++ b/examples/RootNamespaceTest/README.md @@ -11,7 +11,7 @@ When a project sets `Popcorn.Toolkit` in its .csp The project is configured with: - **AssemblyName**: RootNamespaceTest - **RootNamespace**: Popcorn.Toolkit -- **Resources**: Contains sample.txt and config.json +- **Attachments**: Contains sample.txt and config.json ## Expected Behavior diff --git a/examples/RootNamespaceTest/RootNamespaceTest.csproj b/examples/RootNamespaceTest/RootNamespaceTest.csproj index c5412c5..cab5fbf 100644 --- a/examples/RootNamespaceTest/RootNamespaceTest.csproj +++ b/examples/RootNamespaceTest/RootNamespaceTest.csproj @@ -8,7 +8,7 @@ false Popcorn.Toolkit true - Resources + Attachments @@ -20,12 +20,12 @@ - + - +