Skip to content

Commit

Permalink
[wasm] Import StaticWebAssets SDK only for browser-wasm (#41306)
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf authored Jun 6, 2024
1 parent 188b69a commit 11c467f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/WasmSdk/Sdk/Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ Copyright (c) .NET Foundation. All rights reserved.

<_WasmSdkImportsMicrosoftNETSdkPublish Condition="'$(UsingMicrosoftNETSdkPublish)' != 'true'">true</_WasmSdkImportsMicrosoftNETSdkPublish>
<_WasmSdkImportsMicrosoftNETSdkStaticWebAssets Condition="'$(UsingMicrosoftNETSdkStaticWebAssets)' != 'true'">true</_WasmSdkImportsMicrosoftNETSdkStaticWebAssets>
<_WasmSdkImportsMicrosoftNetSdk Condition="'$(UsingMicrosoftNETSdk)' != 'true'">true</_WasmSdkImportsMicrosoftNetSdk>
</PropertyGroup>

<Import Sdk="Microsoft.NET.Sdk.StaticWebAssets" Project="Sdk.props" Condition="'$(_WasmSdkImportsMicrosoftNETSdkStaticWebAssets)' == 'true'" />
<!-- For browser-wasm, we want to import StaticWebAssets SDK which imports SDK. -->
<!-- For wasi-wasm, we don't want to import StaticWebAssets SDK. -->
<!-- This file runs before user csproj is evaluated and thus the switch here is just for completeness - SWA props file will always be imported. -->
<Import Sdk="Microsoft.NET.Sdk.StaticWebAssets" Project="Sdk.props" Condition="'$(RuntimeIdentifier)' == 'browser-wasm' and '$(_WasmSdkImportsMicrosoftNETSdkStaticWebAssets)' == 'true'" />
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" Condition="'$(RuntimeIdentifier)' == 'wasi-wasm' and '$(_WasmSdkImportsMicrosoftNetSdk)' == 'true'" />

<Import Sdk="Microsoft.NET.Sdk.Publish" Project="Sdk.props" Condition="'$(_WasmSdkImportsMicrosoftNETSdkPublish)' == 'true'" />
<Import Project="$(_WebAssemblyPropsFile)" Condition="'$(_WebAssemblyPropsFile)' != ''" />
</Project>
6 changes: 5 additions & 1 deletion src/WasmSdk/Sdk/Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
<Project ToolsVersion="14.0">
<Import Sdk="Microsoft.NET.Sdk.StaticWebAssets" Project="Sdk.targets" Condition="'$(_WasmSdkImportsMicrosoftNETSdkStaticWebAssets)' == 'true'" />
<!-- For browser-wasm, we want to import StaticWebAssets SDK which imports SDK. -->
<!-- For wasi-wasm, we don't want to import StaticWebAssets SDK. -->
<Import Sdk="Microsoft.NET.Sdk.StaticWebAssets" Project="Sdk.targets" Condition="'$(RuntimeIdentifier)' == 'browser-wasm' and '$(_WasmSdkImportsMicrosoftNETSdkStaticWebAssets)' == 'true'" />
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" Condition="'$(RuntimeIdentifier)' == 'wasi-wasm' and '$(_WasmSdkImportsMicrosoftNetSdk)' == 'true'" />

<Import Sdk="Microsoft.NET.Sdk.Publish" Project="Sdk.targets" Condition="'$(_WasmSdkImportsMicrosoftNETSdkPublish)' == 'true'" />
<Import Project="$(_WebAssemblyTargetsFile)" Condition="'$(_WebAssemblyTargetsFile)' != ''" />
</Project>

0 comments on commit 11c467f

Please sign in to comment.