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:
xcopydoesn't work on Linux
Problem 2:
ChromelyBlazor.WebAssemblyshouldn't know anything aboutChromelyBlazor.WebAssemblyAppbecauseChromelyBlazor.WebAssemblyAppis 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.WebAssemblyand 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 1will not work, because_contentdirectory will not be created in theappdirectory.
Solution 2:
- you have to publish
ChromelyBlazor.WebAssemblyso that_contentdirectory will be created (it is not created on build, only on publish) - create a folder publish profile named
FolderProfile.pubxmlinChromelyBlazor.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
wwwrootfolder insideChromelyBlazor.WebAssemblyApp\bin\x64\Debug\net6.0\win-x64so we have to renameapptowwwrootin 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels