Fixes https://github.com/umbraco/Umbraco-CMS/issues/10641 and a couple of other issues with the Umbraco Package dotnet new template.

- Fixed issues with invalid namespace, when using characters like "-"
- Fixed issues with invalid characters in MSBuilder property names, like "."
This commit is contained in:
Bjarke Berg
2021-09-07 10:58:33 +02:00
parent 9a9f61e4c4
commit 981982d87c
3 changed files with 56 additions and 15 deletions

View File

@@ -30,13 +30,53 @@
},
"namespaceReplacer": {
"type": "generated",
"generator": "coalesce",
"generator": "regex",
"dataType": "string",
"replaces": "UmbracoPackage",
"parameters": {
"sourceVariableName": "name",
"defaultValue": "UmbracoPackage",
"fallbackVariableName": "name"
},
"replaces":"UmbracoPackage"
"source": "name",
"steps": [
{
"regex": "\\s",
"replacement": "_"
},
{
"regex": "-",
"replacement": "_"
},
{
"regex": "^[^a-zA-Z_]+",
"replacement": "_"
}
]
}
},
"msbuildReplacer": {
"type": "generated",
"generator": "regex",
"dataType": "string",
"replaces": "UmbracoPackageMsBuild",
"parameters": {
"source": "name",
"steps": [
{
"regex": "\\s",
"replacement": ""
},
{
"regex": "\\.",
"replacement": ""
},
{
"regex": "-",
"replacement": ""
},
{
"regex": "^[^a-zA-Z_]+",
"replacement": ""
}
]
}
},
"Framework": {
"type": "parameter",

View File

@@ -8,6 +8,7 @@
<Description>...</Description>
<Product>...</Product>
<PackageTags>umbraco plugin package</PackageTags>
<RootNamespace>UmbracoPackage</RootNamespace>
</PropertyGroup>
<ItemGroup>

View File

@@ -1,27 +1,27 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<UmbracoPackageContentFilesPath>$(MSBuildThisFileDirectory)..\App_Plugins\UmbracoPackage\**\*.*</UmbracoPackageContentFilesPath>
<UmbracoPackageMsBuildContentFilesPath>$(MSBuildThisFileDirectory)..\App_Plugins\UmbracoPackage\**\*.*</UmbracoPackageMsBuildContentFilesPath>
</PropertyGroup>
<Target Name="CopyUmbracoPackageAssets" BeforeTargets="Build">
<Target Name="CopyUmbracoPackageMsBuildAssets" BeforeTargets="Build">
<ItemGroup>
<UmbracoPackageContentFiles Include="$(UmbracoPackageContentFilesPath)" />
<UmbracoPackageMsBuildContentFiles Include="$(UmbracoPackageMsBuildContentFilesPath)" />
</ItemGroup>
<Message Text="Copying UmbracoPackage files: $(UmbracoPackageContentFilesPath) - #@(UmbracoPackageContentFiles->Count()) files" Importance="high" />
<Message Text="Copying UmbracoPackage files: $(UmbracoPackageMsBuildContentFilesPath) - #@(UmbracoPackageMsBuildContentFiles->Count()) files" Importance="high" />
<Copy
SourceFiles="@(UmbracoPackageContentFiles)"
DestinationFiles="@(UmbracoPackageContentFiles->'$(MSBuildProjectDirectory)\App_Plugins\UmbracoPackage\%(RecursiveDir)%(Filename)%(Extension)')"
SourceFiles="@(UmbracoPackageMsBuildContentFiles)"
DestinationFiles="@(UmbracoPackageMsBuildContentFiles->'$(MSBuildProjectDirectory)\App_Plugins\UmbracoPackage\%(RecursiveDir)%(Filename)%(Extension)')"
SkipUnchangedFiles="true" />
</Target>
<Target Name="ClearUmbracoPackageAssets" BeforeTargets="Clean">
<Target Name="ClearUmbracoPackageMsBuildAssets" BeforeTargets="Clean">
<ItemGroup>
<UmbracoPackageDir Include="$(MSBuildProjectDirectory)\App_Plugins\UmbracoPackage\" />
<UmbracoPackageMsBuildDir Include="$(MSBuildProjectDirectory)\App_Plugins\UmbracoPackage\" />
</ItemGroup>
<Message Text="Clear old UmbracoPackage data" Importance="high" />
<RemoveDir Directories="@(UmbracoPackageDir)" />
<RemoveDir Directories="@(UmbracoPackageMsBuildDir)" />
</Target>
</Project>