Skip to content

Commit e59581b

Browse files
authored
Initial tweaks to the project generation (#923)
1 parent 83400d9 commit e59581b

File tree

3 files changed

+21
-38
lines changed

3 files changed

+21
-38
lines changed

crates/csharp/src/csproj.rs

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,6 @@ impl CSProjectMonoBuilder {
185185

186186
let aot = self.aot;
187187

188-
fs::write(
189-
self.dir.join("rd.xml"),
190-
format!(
191-
r#"<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
192-
<Application>
193-
<Assembly Name="{name}">
194-
</Assembly>
195-
</Application>
196-
</Directives>"#
197-
),
198-
)?;
199-
200188
let maybe_aot = match aot {
201189
true => format!("<WasmBuildNative>{aot}</WasmBuildNative>"),
202190
false => String::new(),
@@ -208,13 +196,11 @@ impl CSProjectMonoBuilder {
208196
<PropertyGroup>
209197
<TargetFramework>net9.0</TargetFramework>
210198
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
211-
212-
<TargetOs>wasi</TargetOs>
199+
<OutputType>Library</OutputType>
213200
{maybe_aot}
201+
<RunAOTCompilation>{aot}</RunAOTCompilation>
214202
<WasmNativeStrip>false</WasmNativeStrip>
215-
<IsBrowserWasmProject>false</IsBrowserWasmProject>
216203
<WasmSingleFileBundle>true</WasmSingleFileBundle>
217-
218204
<RootNamespace>{name}</RootNamespace>
219205
<ImplicitUsings>enable</ImplicitUsings>
220206
<Nullable>enable</Nullable>
@@ -227,32 +213,27 @@ impl CSProjectMonoBuilder {
227213
</PropertyGroup>
228214
229215
<ItemGroup>
230-
<NativeLibrary Include=\"{camel}_component_type.o\" />
216+
<NativeFileReference Include=\"{camel}_component_type.o\" Condition=\"Exists('{camel}_component_type.o')\"/>
231217
</ItemGroup>
232218
233-
<ItemGroup>
234-
<RdXmlFile Include=\"rd.xml\" />
235-
</ItemGroup>
236219
"
237220
);
238221

239-
if self.aot {
240-
fs::write(
241-
self.dir.join("nuget.config"),
242-
r#"<?xml version="1.0" encoding="utf-8"?>
243-
<configuration>
244-
<config>
245-
<add key="globalPackagesFolder" value=".packages" />
246-
</config>
247-
<packageSources>
248-
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
249-
<clear />
250-
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
251-
<add key="dotnet9" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json" />
252-
</packageSources>
253-
</configuration>"#,
254-
)?;
255-
}
222+
fs::write(
223+
self.dir.join("nuget.config"),
224+
r#"<?xml version="1.0" encoding="utf-8"?>
225+
<configuration>
226+
<config>
227+
<add key="globalPackagesFolder" value=".packages" />
228+
</config>
229+
<packageSources>
230+
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
231+
<clear />
232+
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
233+
<add key="dotnet9" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json" />
234+
</packageSources>
235+
</configuration>"#,
236+
)?;
256237

257238
if self.clean_targets {
258239
let mut wasm_filename = self.dir.join(name);

crates/csharp/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,11 +589,13 @@ impl WorldGenerator for CSharp {
589589

590590
wasm_import_linakge_src.push_str(
591591
r#"
592+
#if !NET9_0_OR_GREATER
592593
// temporarily add this attribute until it is available in dotnet 9
593594
namespace System.Runtime.InteropServices
594595
{
595596
internal partial class WasmImportLinkageAttribute : Attribute {}
596597
}
598+
#endif
597599
"#,
598600
);
599601
files.push(

crates/csharp/tests/codegen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn mono_verify(dir: &Path, name: &str) {
182182
let wasm_filename = dir.join(name);
183183

184184
cmd.arg("build")
185-
.arg(dir.join(format!("TheWorld.csproj")))
185+
.arg(dir.join(format!("TheWorldWorld.csproj")))
186186
.arg("-c")
187187
.arg("Debug")
188188
.arg("-o")

0 commit comments

Comments
 (0)