Skip to content

Commit

Permalink
feat: Add Microsoft.NET.Sdk.WebAssembly support
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Sep 13, 2024
1 parent 6e0713f commit 2a3de68
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
<PackageReference Update="Uno.Core.Extensions.Disposables" Version="4.0.1" />
<PackageReference Update="Uno.Core.Extensions.Compatibility" Version="4.0.1" />
<PackageReference Update="Uno.Diagnostics.Eventing" Version="2.0.1" />
<PackageReference Update="Uno.Wasm.Bootstrap" Version="9.0.0-dev.86" />
<PackageReference Update="Uno.Wasm.Bootstrap.DevServer" Version="9.0.0-dev.86" />
<PackageReference Update="Uno.Wasm.Bootstrap" Version="9.0.0-dev.270" />
<PackageReference Update="Uno.Wasm.Bootstrap.DevServer" Version="9.0.0-dev.270" />
<PackageReference Update="MSTest" Version="3.3.1" />
<PackageReference Update="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Update="MSTest.TestAdapter" Version="3.3.1" />
Expand Down
4 changes: 2 additions & 2 deletions src/SamplesApp/SamplesApp.Wasm/SamplesApp.Wasm.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.WebAssembly">
<PropertyGroup>
<TargetFrameworks>$(NetWasmPreviousAndCurrent)</TargetFrameworks>
</PropertyGroup>
Expand All @@ -9,7 +9,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<DefineConstants>$(DefineConstants);__WASM__;HAS_UNO;UNO_REFERENCE_API</DefineConstants>
<NoWarn>$(NoWarn);NU1701;CS1998;NU1504;UXAML0002</NoWarn>
<NoWarn>$(NoWarn);NU1701;CS1998;NU1504;UXAML0002;NU1903;NU1902;IL2026;IL2072;IL2067;IL2075;IL2070;IL2077;IL2057</NoWarn>
<IsUiAutomationMappingEnabled>true</IsUiAutomationMappingEnabled>
<UseUnoXamlParser>true</UseUnoXamlParser>
<UnoRuntimeIdentifier>WebAssembly</UnoRuntimeIdentifier>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,21 @@
</ItemGroup>
</Target>

<PropertyGroup>
<_UnoAddLibraryAssetsBeforeTargets>
$(_UnoAddLibraryAssetsBeforeTargets);
GetCopyToOutputDirectoryItems;
GenerateUnoWasmAssets;
</_UnoAddLibraryAssetsBeforeTargets>
</PropertyGroup>

<!--
Populate output groups when building heads
-->
<Target Name="_UnoAddLibraryAssets"
Condition="'$(IsUnoHead)'=='true' or '$(AndroidApplication)'=='true' or '$(ProjectTypeGuids)'!=''"
DependsOnTargets="_UnoFindPackageAssetMarkers"
BeforeTargets="GetCopyToOutputDirectoryItems">
BeforeTargets="$(_UnoAddLibraryAssetsBeforeTargets)">

<ExpandPackageAssets_v0 MarkerFiles="@(_UnoPriFiles)">
<Output TaskParameter="Assets" ItemName="_UnoAssetsFilesExpanded" />
Expand Down
11 changes: 9 additions & 2 deletions src/Uno.Sdk/Sdk/Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ Copyright (C) Uno Platform Inc. All rights reserved.
<!-- Legacy Project System Support -->
<_DefaultMicrosoftNETSdk Condition="$(SingleProject) != 'true' AND $(UnoSingleProject) != 'true' AND ($(MSBuildProjectName.EndsWith('.Wasm')) or $(MSBuildProjectName.EndsWith('.WebAssembly')))">Microsoft.NET.Sdk.Web</_DefaultMicrosoftNETSdk>

<_DefaultMicrosoftNETSdk Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'browserwasm'" >Microsoft.NET.Sdk.Web</_DefaultMicrosoftNETSdk>
<_UnoUseMicrosoftNETSdkWebAssembly Condition="
$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'browserwasm'
AND $([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &lt; 9.0
">true</_UnoUseMicrosoftNETSdkWebAssembly>

<_DefaultMicrosoftNETSdk Condition=" '$(_UnoUseMicrosoftNETSdkWebAssembly)' == '' ">Microsoft.NET.Sdk.Web</_DefaultMicrosoftNETSdk>
<_DefaultMicrosoftNETSdk Condition=" '$(_UnoUseMicrosoftNETSdkWebAssembly)' == 'true' " >Microsoft.NET.Sdk.WebAssembly</_DefaultMicrosoftNETSdk>

<_DefaultMicrosoftNETSdk Condition=" $(_DefaultMicrosoftNETSdk) == '' ">Microsoft.NET.Sdk</_DefaultMicrosoftNETSdk>

<_DefaultWasmOutputType Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'browserwasm'">$(OutputType)</_DefaultWasmOutputType>
Expand Down Expand Up @@ -73,7 +80,7 @@ Copyright (C) Uno Platform Inc. All rights reserved.
VS to read the global properties and avoid showing a yellow icon being the result of a mismatch
between runs of design-time builds (one build defining a FrameworkReference and another one not).
-->
<ItemGroup>
<ItemGroup Condition=" '$(_UnoUseMicrosoftNETSdkWebAssembly)' == 'false' ">
<FrameworkReference Remove="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>

0 comments on commit 2a3de68

Please sign in to comment.