umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.42k stars 2.67k forks source link

umbraco/config/lang missing on dotnet publish --no-build #11662

Closed p-m-j closed 2 years ago

p-m-j commented 2 years ago

Which exact Umbraco version are you using? For example: 9.0.1 - don't just write v9

9.1.0

Bug summary

See title.

Workaround

don't --no-build when publishing, you can even skip the dotnet build step and just dotnet publish as long as --no-build is not present (9.1.0+)

Specifics

No response

Steps to reproduce

Create a new umbraco 9.1.0 project

$ dotnet new umbraco --name repro
$ cd ./repro
$ dotnet build
$ dotnet publish -o dist --no-build --no-restore
$ ls ./dist/umbraco/config
# no lang dir

Expected result / actual result

lang dir created and populated


_This item has been added to our backlog AB#15174_

p-m-j commented 2 years ago

GetCopyToOutputDirectoryItems doesn't run when publish --no-build and therefore IncludeUmbracoFolderContent doesn't run.

See https://github.com/umbraco/Umbraco-CMS/blob/v9/contrib/build/NuSpecs/buildTransitive/Umbraco.Cms.StaticAssets.targets

sitereactor commented 2 years ago

FWIW the csproj for 9.0.0 and 9.01 looked like this

<Project Sdk="Microsoft.NET.Sdk.Web">

    <PropertyGroup>
        <TargetFramework>net5.0</TargetFramework>
        <DefaultItemExcludes>$(DefaultItemExcludes);App_Plugins/**;</DefaultItemExcludes>
        <DefaultItemExcludes>$(DefaultItemExcludes);umbraco/**;</DefaultItemExcludes>
        <DefaultItemExcludes>$(DefaultItemExcludes);wwwroot/media/**;</DefaultItemExcludes>
    </PropertyGroup>

    <!-- Force windows to use ICU. Otherwise Windows 10 2019H1+ will do it, but older windows 10 and most if not all winodws servers will run NLS -->
    <ItemGroup Condition="'$(OS)' == 'Windows_NT'">
        <PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.6" />
        <RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2" />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Umbraco.Cloud.Identity.Cms" Version="4.0.50" />
        <PackageReference Include="Umbraco.Cloud.StorageProviders.AzureBlob" Version="4.0.0" />
        <PackageReference Include="Umbraco.Cms" Version="9.1.0" />
        <PackageReference Include="Umbraco.Deploy.Cloud" Version="9.1.0" />
        <PackageReference Include="Umbraco.Deploy.Contrib" Version="9.0.0" />
        <PackageReference Include="Umbraco.Deploy.Forms" Version="9.1.0" />
        <PackageReference Include="Umbraco.Forms" Version="9.1.0" />
    </ItemGroup>

    <ItemGroup>
        <Content Include="App_Plugins/**" CopyToOutputDirectory="Always" />
        <Content Include="umbraco/**" CopyToOutputDirectory="Always" />
        <Content Remove="umbraco/Data/**" />
        <Content Remove="umbraco/Logs/**" />
        <Content Remove="umbraco/mediacache/**" />
        <Content Remove="umbraco/models/**" />
        <Compile Include="umbraco/models/**" Exclude="**/*.flag" />
    </ItemGroup>

    <PropertyGroup>
        <CopyRazorGenerateFilesToPublishDirectory>true</CopyRazorGenerateFilesToPublishDirectory>
    </PropertyGroup>

    <!-- Set this to true if ModelsBuilder mode is not InMemoryAuto-->
    <PropertyGroup>
        <RazorCompileOnBuild>false</RazorCompileOnBuild>
        <RazorCompileOnPublish>false</RazorCompileOnPublish>
    </PropertyGroup>
</Project>

whereas in 9.1.0 it looks like this (when using the dotnet new template):

<Project Sdk="Microsoft.NET.Sdk.Web">
    <PropertyGroup>
        <TargetFramework>net5.0</TargetFramework>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Umbraco.Cloud.Identity.Cms" Version="4.0.50" />
        <PackageReference Include="Umbraco.Cloud.StorageProviders.AzureBlob" Version="4.0.0" />
        <PackageReference Include="Umbraco.Cms" Version="9.1.0" />
        <PackageReference Include="Umbraco.Deploy.Cloud" Version="9.1.0" />
        <PackageReference Include="Umbraco.Deploy.Contrib" Version="9.0.0" />
        <PackageReference Include="Umbraco.Deploy.Forms" Version="9.1.0" />
        <PackageReference Include="Umbraco.Forms" Version="9.1.0" />
    </ItemGroup>

    <!-- Force windows to use ICU. Otherwise Windows 10 2019H1+ will do it, but older windows 10 and most if not all winodws servers will run NLS -->
    <ItemGroup Condition="'$(OS)' == 'Windows_NT'">
        <PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
        <RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2" />
    </ItemGroup>

    <PropertyGroup>
        <CopyRazorGenerateFilesToPublishDirectory>true</CopyRazorGenerateFilesToPublishDirectory>
    </PropertyGroup>

    <!-- Set this to true if ModelsBuilder mode is not InMemoryAuto-->
    <PropertyGroup>
        <RazorCompileOnBuild>false</RazorCompileOnBuild>
        <RazorCompileOnPublish>false</RazorCompileOnPublish>
    </PropertyGroup>
</Project>

I know that you mentioned that these should not be necessary anymore, but if I add them back in, in a 9.1.0 project (both the items under the PropertyGroup at the top and the ItemGroup) then it works as expected on Umbraco Cloud.

p-m-j commented 2 years ago

Yep that's how it used to work, it may be that adding to the content item is the fix but should be applied in targets files instead of polluting the csproj, however that will cause us issues with duplicates for those upgrading from 9.0.0 (as their csproj will also add to content item).

Will come up with something.

sitereactor commented 2 years ago

But if I add those elements back in I don't get 'duplicate property' errors. Just tested it on two different 9.1.0 projects.

p-m-j commented 2 years ago

If you content include in csproj (e.g. those upgrading from 9.0.0), and we add in static assets.targets for 9.1.1 you would get errors, came up in the iterations that led us to where we are now.

Some history here https://github.com/umbraco/Umbraco-CMS/pull/11211