This repository was archived by the owner on Jan 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
This repository was archived by the owner on Jan 15, 2023. It is now read-only.
I solved all ChromelyBlazor.WebAssembly build problems #109
Copy link
Copy link
Open
Description
Problem 1:
xcopy
doesn't work on Linux
Problem 2:
ChromelyBlazor.WebAssembly
shouldn't know anything aboutChromelyBlazor.WebAssemblyApp
becauseChromelyBlazor.WebAssemblyApp
is usingChromelyBlazor.WebAssembly
Solution 1:
- Remove this from
ChromelyBlazor.WebAssembly
:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy "$(ProjectDir)wwwroot" "$(SolutionDir)\ChromelyBlazor.WebAssemblyApp\bin\x64\Debug\net6.0\win-x64\app" /i /s /r /y /c
xcopy "$(TargetDir)wwwroot" "$(SolutionDir)\ChromelyBlazor.WebAssemblyApp\bin\x64\Debug\net6.0\win-x64\app" /i /s /r /y /c" />
</Target>
- Add this to
ChromelyBlazor.WebAssemblyApp
:
<ItemGroup>
<None Include="$(SolutionDir)ChromelyBlazor.WebAssembly\wwwroot\**" CopyToOutputDirectory="PreserveNewest" LinkBase="app\" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<ItemGroup>
<AfterBuildWwwRoot Include="$(SolutionDir)ChromelyBlazor.WebAssembly\bin\$(ConfigurationName)\$(TargetFramework)\wwwroot\**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(AfterBuildWwwRoot)" DestinationFiles="@(AfterBuildWwwRoot->'$(TargetDir)\app\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>
Problem 3:
- If you add any NuGet that has its own wwwroot content to the
ChromelyBlazor.WebAssembly
and use it there like this:
<link href="_content/Blazorise/blazorise.css" rel="stylesheet" />
or like this:
<script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"></script>
thenSolution 1
will not work, because_content
directory will not be created in theapp
directory.
Solution 2:
- you have to publish
ChromelyBlazor.WebAssembly
so that_content
directory will be created (it is not created on build, only on publish) - create a folder publish profile named
FolderProfile.pubxml
inChromelyBlazor.WebAssembly
- Visual Studio will save it as
ChromelyBlazor.WebAssembly\Properties\PublishProfiles\FolderProfile.pubxml
- add this to
ChromelyBlazor.WebAssemblyApp
:
<PropertyGroup>
<PublishProfileDirectory>$(SolutionDir)ChromelyBlazor.WebAssembly\Properties\PublishProfiles</PublishProfileDirectory>
<PublishProfileFileName>FolderProfile</PublishProfileFileName>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<MSBuild
Projects="$(SolutionDir)ChromelyBlazor.WebAssembly\ChromelyBlazor.WebAssembly.csproj"
Properties="DeployOnBuild=true;PublishProfile=$(PublishProfileFileName);PublishProfileRootFolder=$(PublishProfileDirectory);PublishUrl=$(TargetDir);PlatformTarget=AnyCPU" />
</Target>
- publish will automatically create a
wwwroot
folder insideChromelyBlazor.WebAssemblyApp\bin\x64\Debug\net6.0\win-x64
so we have to renameapp
towwwroot
in our code - change
config.StartUrl = "http://app/index.html";
toconfig.StartUrl = "http://wwwroot/index.html";
- change
new UrlScheme(DefaultSchemeName.LOCALREQUEST, "http", "app", string.Empty, UrlSchemeType.LocalResource, false)
to
new UrlScheme(DefaultSchemeName.LOCALREQUEST, "http", "wwwroot", string.Empty, UrlSchemeType.LocalResource, false)
You can see a working solution here: https://github.com/Jinjinov/Ididit/blob/main/Ididit.Wasm.Chromely/Ididit.Wasm.Chromely.csproj
Metadata
Metadata
Assignees
Labels
No labels