Search code examples
c#.netasp.net-coreblazorrazor-pages

Publishing .Net Core Blazor Web Assembly Client-Server Project


I have developed the Blazor Client Server Web Assembly project using dot Net Core 8.0 using C# and found running successfully on the server by push the published files but did not find any .razor pages there in published directory. I mean either components from server project and pages directory from web assembly client project. how to include these pages in published directory to update frequent page level changes in the future?

I have tried different configuration changes in solution file but it did not work.

Regards, Manoj


Solution

  • It is not the solution file. You could using following settings .csproj file to copy folder when publish.

    server.csproj

        <Target Name="CopyComponents" BeforeTargets="Publish">
            <ItemGroup>
                <MyFiles Include="Components\**" />
            </ItemGroup>
            <Copy SourceFiles="@(MyFiles)" DestinationFolder="$(PublishDir)\Components\%(RecursiveDir)\" />
        </Target>
        <Target Name="CopyPages" BeforeTargets="Publish">
            <ItemGroup>
                <MyFiles2 Include="..\BlazorApp28.Client\Pages\**" />
            </ItemGroup>
            <Copy SourceFiles="@(MyFiles2)" DestinationFolder="$(PublishDir)\Pages" />
        </Target>
    

    Explaination: using ..\BlazorApp28.Client to reference client project in server.csproj