Skip to content

Commit

Permalink
Fix: The publishing process on Visual Studio IDE was failed.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsakamoto committed Sep 3, 2023
1 parent 9929218 commit d5ae7df
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
26 changes: 26 additions & 0 deletions BlazorWasmPreRendering.Build.Test/ProgramE2ETest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,32 @@ public async Task Publish_Test()
}
}

[Test, Platform("Win")]
public async Task Publish_by_native_msbuild_Test()
{
// Given
var processorArchitecture = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE")?.ToLower() ?? ".";
var vsInstallDir = Environment.GetEnvironmentVariable("VSINSTALLDIR");
if (vsInstallDir == null) Assert.Inconclusive(@"This test requires Visual Studio and the definition of the ""VSINSTALLDIR"" environment variable to point out the directory where Visual Studio is installed. (ex: VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio\2022\Community\)");
var msbuildPath = Path.Combine(vsInstallDir, "MSBuild", "Current", "Bin", processorArchitecture, "MSBuild.exe");

using var workDir = SampleSite.CreateSampleAppsWorkDir();
var app0Dir = Path.Combine(workDir, "BlazorWasmApp0");

// When
await Start("dotnet", "restore", app0Dir).WaitForExitAsync();
var msbuild = await Start(msbuildPath,
"-p:Configuration=Debug -p:BlazorEnableCompression=false -p:DeployOnBuild=true -p:PublishUrl=bin/publish",
app0Dir).WaitForExitAsync();
msbuild.ExitCode.Is(0, message: msbuild.StdOutput + msbuild.StdError);

// Then

// Validate prerendered contents.
var wwwrootDir = Path.Combine(app0Dir, "bin", "publish", "wwwroot");
ValidatePrerenderedContentsOfApp0(wwwrootDir);
}

[Test]
public async Task Publish_by_msbuild_Test()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<BlazorWasmPrerenderingKeepServer Condition=" '$(BlazorWasmPrerenderingKeepServer)' == '' ">false</BlazorWasmPrerenderingKeepServer>
<BlazorWasmPrerenderingDeleteLoadingContents Condition=" '$(BlazorWasmPrerenderingKeepServer)' == '' ">false</BlazorWasmPrerenderingDeleteLoadingContents>
<BlazorWasmPrerenderingServerPort Condition=" '$(BlazorWasmPrerenderingServerPort)' == '' ">5050-5999</BlazorWasmPrerenderingServerPort>
<BlazorWasmPrerenderingDotNetHost Condition=" '$(BlazorWasmPrerenderingDotNetHost)' == '' ">$(DOTNET_HOST_PATH)</BlazorWasmPrerenderingDotNetHost>
<BlazorWasmPrerenderingDotNetHost Condition=" '$(BlazorWasmPrerenderingDotNetHost)' == '' ">$(_DotNetHostDirectory)$(_DotNetHostFileName)</BlazorWasmPrerenderingDotNetHost>
</PropertyGroup>
</Target>

Expand Down Expand Up @@ -60,6 +62,6 @@
<BlazorWasmPrerenderingDeleteLoadingContentsSwitch Condition=" '$(BlazorWasmPrerenderingDeleteLoadingContents)' == 'true' "> -d</BlazorWasmPrerenderingDeleteLoadingContentsSwitch>
</PropertyGroup>

<Exec Command="&quot;$(DOTNET_HOST_PATH)&quot; &quot;$(BlazorWasmPrerenderingServerDll)&quot; --assemblyname &quot;$(BlazorWasmPrerenderingAssembly)&quot; -t &quot;$(BlazorWasmPrerenderingRootComponentType)&quot; --selectorofrootcomponent &quot;$(BlazorWasmPrerenderingRootComponentSelector)&quot; --selectorofheadoutletcomponent &quot;$(BlazorWasmPrerenderingHeadOutletComponentSelector)&quot; -p &quot;$(BlazorWasmPrerenderingPublishDir)&quot; -i &quot;$(BlazorWasmPrerenderingIntermediateDir)&quot; --assemblydir &quot;$(BlazorWasmPrerenderingTargetDir)&quot; -m &quot;$(BlazorWasmPrerenderingMiddlewareArg)&quot; -f &quot;$(BlazorWasmPrerenderingTFM)&quot; --serviceworkerassetsmanifest &quot;$(ServiceWorkerAssetsManifest)&quot; --environment &quot;$(BlazorWasmPrerenderingEnvironment)&quot; --emulateauthme &quot;$(BlazorWasmPrerenderingEmulateAuthMe)&quot; --locale &quot;$(BlazorWasmPrerenderingLocale)&quot; -o &quot;$(BlazorWasmPrerenderingOutputStyle)&quot; $(BlazorWasmPrerenderingKeepServerSwitch)$(BlazorWasmPrerenderingDeleteLoadingContentsSwitch) -u &quot;$(BlazorWasmPrerenderingUrlPathToExplicitFetch)&quot; -r &quot;$(BlazorWasmPrerenderingMode)&quot; --serverport &quot;$(BlazorWasmPrerenderingServerPort)&quot; --bwapoptionsdllext &quot;$(BlazorWasmPrerenderingBWAPDllExt)&quot;" />
<Exec Command="&quot;$(BlazorWasmPrerenderingDotNetHost)&quot; &quot;$(BlazorWasmPrerenderingServerDll)&quot; --assemblyname &quot;$(BlazorWasmPrerenderingAssembly)&quot; -t &quot;$(BlazorWasmPrerenderingRootComponentType)&quot; --selectorofrootcomponent &quot;$(BlazorWasmPrerenderingRootComponentSelector)&quot; --selectorofheadoutletcomponent &quot;$(BlazorWasmPrerenderingHeadOutletComponentSelector)&quot; -p &quot;$(BlazorWasmPrerenderingPublishDir)&quot; -i &quot;$(BlazorWasmPrerenderingIntermediateDir)&quot; --assemblydir &quot;$(BlazorWasmPrerenderingTargetDir)&quot; -m &quot;$(BlazorWasmPrerenderingMiddlewareArg)&quot; -f &quot;$(BlazorWasmPrerenderingTFM)&quot; --serviceworkerassetsmanifest &quot;$(ServiceWorkerAssetsManifest)&quot; --environment &quot;$(BlazorWasmPrerenderingEnvironment)&quot; --emulateauthme &quot;$(BlazorWasmPrerenderingEmulateAuthMe)&quot; --locale &quot;$(BlazorWasmPrerenderingLocale)&quot; -o &quot;$(BlazorWasmPrerenderingOutputStyle)&quot; $(BlazorWasmPrerenderingKeepServerSwitch)$(BlazorWasmPrerenderingDeleteLoadingContentsSwitch) -u &quot;$(BlazorWasmPrerenderingUrlPathToExplicitFetch)&quot; -r &quot;$(BlazorWasmPrerenderingMode)&quot; --serverport &quot;$(BlazorWasmPrerenderingServerPort)&quot; --bwapoptionsdllext &quot;$(BlazorWasmPrerenderingBWAPDllExt)&quot;" />
</Target>
</Project>

0 comments on commit d5ae7df

Please sign in to comment.