From 4cd6a55c8c060c868433619b641939e5e964c108 Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Sun, 9 Jun 2024 01:02:47 -0300 Subject: [PATCH] Refactor common files and resources into a shared project Instead of linked files which is less intuitive and manageable. --- ThisAssembly.sln | 14 ++++++-- src/Directory.props | 4 --- src/Directory.targets | 6 ---- src/{ => Shared}/EmbeddedResource.cs | 0 src/{ => Shared}/PathSanitizer.cs | 0 src/Shared/Shared.projitems | 31 +++++++++++++++++ src/Shared/Shared.shproj | 16 +++++++++ src/Shared/ThisAssembly.Prerequisites.targets | 33 +++++++++++++++++++ .../ThisAssembly.AssemblyInfo.csproj | 2 ++ .../ThisAssembly.Constants.csproj | 2 ++ src/ThisAssembly.Git/ThisAssembly.Git.csproj | 2 ++ .../ThisAssembly.Metadata.csproj | 2 ++ .../ThisAssembly.Project.csproj | 2 ++ .../ResourcesGenerator.cs | 2 +- .../ThisAssembly.Resources.csproj | 8 +++-- .../ThisAssembly.Strings.csproj | 2 ++ .../ThisAssembly.Tests.csproj | 2 +- src/ThisAssembly/ThisAssembly.csproj | 3 +- 18 files changed, 113 insertions(+), 18 deletions(-) rename src/{ => Shared}/EmbeddedResource.cs (100%) rename src/{ => Shared}/PathSanitizer.cs (100%) create mode 100644 src/Shared/Shared.projitems create mode 100644 src/Shared/Shared.shproj create mode 100644 src/Shared/ThisAssembly.Prerequisites.targets diff --git a/ThisAssembly.sln b/ThisAssembly.sln index 04847acd..de64e3a4 100644 --- a/ThisAssembly.sln +++ b/ThisAssembly.sln @@ -10,9 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .editorconfig = .editorconfig src\Directory.props = src\Directory.props src\Directory.targets = src\Directory.targets - src\Directory.targets.user = src\Directory.targets.user readme.md = readme.md - src\ThisAssembly.Prerequisites.targets = src\ThisAssembly.Prerequisites.targets EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThisAssembly", "src\ThisAssembly\ThisAssembly.csproj", "{D3A47732-4937-4B6E-BCD1-66896D04E20D}" @@ -40,6 +38,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThisAssembly.Resources", "s EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThisAssembly.Git", "src\ThisAssembly.Git\ThisAssembly.Git.csproj", "{F34F8470-7C60-4BB8-ACB5-569D6D0F6A46}" EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Shared", "src\Shared\Shared.shproj", "{8E0F2A43-C9AF-4E46-BF70-CF8645371C12}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -92,4 +92,14 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {ADF2DC9F-5F77-4F6E-8804-CFF5892CD064} EndGlobalSection + GlobalSection(SharedMSBuildProjectFiles) = preSolution + src\Shared\Shared.projitems*{14d0c5ba-8410-4454-87a2-7bf5993e1ea2}*SharedItemsImports = 5 + src\Shared\Shared.projitems*{31c53cce-13fc-4890-803a-85cd146b909b}*SharedItemsImports = 5 + src\Shared\Shared.projitems*{3e7158b5-bfef-4416-8226-9096c7c98268}*SharedItemsImports = 5 + src\Shared\Shared.projitems*{8e0f2a43-c9af-4e46-bf70-cf8645371c12}*SharedItemsImports = 13 + src\Shared\Shared.projitems*{a91c7a07-ffd6-4d19-bd78-b0bc8f9267db}*SharedItemsImports = 5 + src\Shared\Shared.projitems*{b5007099-8be7-490b-9e9a-18cc50c92c29}*SharedItemsImports = 5 + src\Shared\Shared.projitems*{cddf83bc-70be-46c3-bd79-524d868a2812}*SharedItemsImports = 5 + src\Shared\Shared.projitems*{f34f8470-7c60-4bb8-acb5-569d6d0f6a46}*SharedItemsImports = 5 + EndGlobalSection EndGlobal diff --git a/src/Directory.props b/src/Directory.props index 85c325ad..fe3cc80f 100644 --- a/src/Directory.props +++ b/src/Directory.props @@ -25,8 +25,4 @@ false - - - - diff --git a/src/Directory.targets b/src/Directory.targets index 5ecd2448..357eaef1 100644 --- a/src/Directory.targets +++ b/src/Directory.targets @@ -7,12 +7,6 @@ - - - diff --git a/src/EmbeddedResource.cs b/src/Shared/EmbeddedResource.cs similarity index 100% rename from src/EmbeddedResource.cs rename to src/Shared/EmbeddedResource.cs diff --git a/src/PathSanitizer.cs b/src/Shared/PathSanitizer.cs similarity index 100% rename from src/PathSanitizer.cs rename to src/Shared/PathSanitizer.cs diff --git a/src/Shared/Shared.projitems b/src/Shared/Shared.projitems new file mode 100644 index 00000000..fe0ecc79 --- /dev/null +++ b/src/Shared/Shared.projitems @@ -0,0 +1,31 @@ + + + true + 8e0f2a43-c9af-4e46-bf70-cf8645371c12 + + + + + + + + + + + %(RecursiveDir)%(Filename)%(Extension) + + + %(RecursiveDir)%(Filename)%(Extension) + + + %(RecursiveDir)%(Filename)%(Extension) + + + + + + PreserveNewest + build\$(TargetFramework)\%(Filename)%(Extension) + + + \ No newline at end of file diff --git a/src/Shared/Shared.shproj b/src/Shared/Shared.shproj new file mode 100644 index 00000000..21876c3d --- /dev/null +++ b/src/Shared/Shared.shproj @@ -0,0 +1,16 @@ + + + 8e0f2a43-c9af-4e46-bf70-cf8645371c12 + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Shared/ThisAssembly.Prerequisites.targets b/src/Shared/ThisAssembly.Prerequisites.targets new file mode 100644 index 00000000..ed7f095e --- /dev/null +++ b/src/Shared/ThisAssembly.Prerequisites.targets @@ -0,0 +1,33 @@ + + + + + 4.0 + + + + + + + + + + $(CompilerApiVersion.Substring(6)) + 0.0 + + + + + + + + true + + + diff --git a/src/ThisAssembly.AssemblyInfo/ThisAssembly.AssemblyInfo.csproj b/src/ThisAssembly.AssemblyInfo/ThisAssembly.AssemblyInfo.csproj index 29882c04..485ac034 100644 --- a/src/ThisAssembly.AssemblyInfo/ThisAssembly.AssemblyInfo.csproj +++ b/src/ThisAssembly.AssemblyInfo/ThisAssembly.AssemblyInfo.csproj @@ -51,4 +51,6 @@ on the `ThisAssembly.Info` class. + + diff --git a/src/ThisAssembly.Constants/ThisAssembly.Constants.csproj b/src/ThisAssembly.Constants/ThisAssembly.Constants.csproj index b6e5731d..98bc1bcf 100644 --- a/src/ThisAssembly.Constants/ThisAssembly.Constants.csproj +++ b/src/ThisAssembly.Constants/ThisAssembly.Constants.csproj @@ -67,4 +67,6 @@ C#: + + diff --git a/src/ThisAssembly.Git/ThisAssembly.Git.csproj b/src/ThisAssembly.Git/ThisAssembly.Git.csproj index 75d27fa0..387072ba 100644 --- a/src/ThisAssembly.Git/ThisAssembly.Git.csproj +++ b/src/ThisAssembly.Git/ThisAssembly.Git.csproj @@ -42,4 +42,6 @@ + + diff --git a/src/ThisAssembly.Metadata/ThisAssembly.Metadata.csproj b/src/ThisAssembly.Metadata/ThisAssembly.Metadata.csproj index 611049a2..0b4e6fa7 100644 --- a/src/ThisAssembly.Metadata/ThisAssembly.Metadata.csproj +++ b/src/ThisAssembly.Metadata/ThisAssembly.Metadata.csproj @@ -63,4 +63,6 @@ C#: + + diff --git a/src/ThisAssembly.Project/ThisAssembly.Project.csproj b/src/ThisAssembly.Project/ThisAssembly.Project.csproj index 4b364b3c..ef6e7046 100644 --- a/src/ThisAssembly.Project/ThisAssembly.Project.csproj +++ b/src/ThisAssembly.Project/ThisAssembly.Project.csproj @@ -58,4 +58,6 @@ C#: + + diff --git a/src/ThisAssembly.Resources/ResourcesGenerator.cs b/src/ThisAssembly.Resources/ResourcesGenerator.cs index a8164ed5..0e0d4e28 100644 --- a/src/ThisAssembly.Resources/ResourcesGenerator.cs +++ b/src/ThisAssembly.Resources/ResourcesGenerator.cs @@ -16,7 +16,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) { context.RegisterPostInitializationOutput( spc => spc.AddSource( - "ThisAssembly.Resources.EmbeddedResource.cs", + "ThisAssembly.EmbeddedResource.cs", SourceText.From(EmbeddedResource.GetContent("EmbeddedResource.cs"), Encoding.UTF8))); var files = context.AdditionalTextsProvider diff --git a/src/ThisAssembly.Resources/ThisAssembly.Resources.csproj b/src/ThisAssembly.Resources/ThisAssembly.Resources.csproj index 9a1905bb..f8114f34 100644 --- a/src/ThisAssembly.Resources/ThisAssembly.Resources.csproj +++ b/src/ThisAssembly.Resources/ThisAssembly.Resources.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -40,11 +40,13 @@ - + + + - + diff --git a/src/ThisAssembly.Strings/ThisAssembly.Strings.csproj b/src/ThisAssembly.Strings/ThisAssembly.Strings.csproj index 938565d0..94c1cd8a 100644 --- a/src/ThisAssembly.Strings/ThisAssembly.Strings.csproj +++ b/src/ThisAssembly.Strings/ThisAssembly.Strings.csproj @@ -48,5 +48,7 @@ such as "Hello {name}". + + diff --git a/src/ThisAssembly.Tests/ThisAssembly.Tests.csproj b/src/ThisAssembly.Tests/ThisAssembly.Tests.csproj index c06fcb8d..f35c3183 100644 --- a/src/ThisAssembly.Tests/ThisAssembly.Tests.csproj +++ b/src/ThisAssembly.Tests/ThisAssembly.Tests.csproj @@ -78,7 +78,7 @@ - + diff --git a/src/ThisAssembly/ThisAssembly.csproj b/src/ThisAssembly/ThisAssembly.csproj index 578748be..abf203db 100644 --- a/src/ThisAssembly/ThisAssembly.csproj +++ b/src/ThisAssembly/ThisAssembly.csproj @@ -4,7 +4,8 @@ netstandard2.0 true false - false + + false