Skip to content

Commit

Permalink
feat!: Add support for .NET 7
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The index.html file now requires the use of module initialization:

```html
<script type="module" src="./uno-bootstrap.js"></script>
```

+semver: major
  • Loading branch information
jeromelaban committed Feb 21, 2022
1 parent 1de9d29 commit e4e5f43
Show file tree
Hide file tree
Showing 23 changed files with 2,123 additions and 852 deletions.
7 changes: 7 additions & 0 deletions .vsts-ci.yml
Expand Up @@ -66,6 +66,13 @@ jobs:
OverWrite: false
flattenFolders: false

- task: PublishBuildArtifacts@1
condition: always()
inputs:
PathtoPublish: $(build.artifactstagingdirectory)
ArtifactName: uno-wasm-bootstrap-drop
ArtifactType: Container

- script: |
dotnet msbuild /r /bl /m:1 /p:Configuration=Release /p:DISABLE_CLIHOST_NET6=true /p:InformationalVersion=$(GITVERSION.INFORMATIONALVERSION) /p:PackageVersion=$(GITVERSION.FullSemVer) /p:PackageOutputPath=$(build.sourcesdirectory)\build\nuget $(build.sourcesdirectory)/src/Uno.Wasm.Bootstrap-msbuild-only.slnf /bl:$(build.artifactstagingdirectory)/win-validation-binaries.binlog
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.Wasm.Bootstrap/Constants.cs
Expand Up @@ -7,7 +7,7 @@ namespace Uno.Wasm.Bootstrap
internal class Constants
{
public const string DefaultDotnetRuntimeSdkUrl = "https://unowasmbootstrap.azureedge.net/runtime/"
+ "dotnet-runtime-wasm-linux-bd114dd-53ca85fb900-1877706367-Release.zip";
+ "dotnet-runtime-wasm-linux-e1fce2c-a1f0147eb6c-1877706756-Release.zip";

/// <summary>
/// Min version of the emscripten SDK. Must be aligned with dotnet/runtime SDK build in <see cref="NetCoreWasmSDKUri"/>.
Expand Down
19 changes: 11 additions & 8 deletions src/Uno.Wasm.Bootstrap/ShellTask.cs
Expand Up @@ -928,7 +928,7 @@ private void RunPackager()
}

//
// The linker removes files after the mono-config.js file has been
// The linker removes files after the mono-config.json file has been
// generated by the packager. Synchronize the list with the actual list.
//
var deletedFiles = Directory
Expand All @@ -939,15 +939,15 @@ private void RunPackager()
.Select(Path.GetFileName)
);

string monoConfigFilePath = Path.Combine(_workDistPath, "mono-config.js");
string monoConfigFilePath = Path.Combine(_workDistPath, "mono-config.json");
var monoConfig = File.ReadAllText(monoConfigFilePath);

foreach (var deletedFile in deletedFiles)
{
Log.LogMessage($"Removing linker deleted file [{deletedFile}] from mono-config.js");
Log.LogMessage($"Removing linker deleted file [{deletedFile}] from mono-config.json");
monoConfig = monoConfig
.Replace($"\"{deletedFile}\",", "")
.Replace($"\"{deletedFile}\"", "");
.Replace($"{{ \"name\": \"{deletedFile}\", \"behavior\":\"assembly\" }},", "")
.Replace($"{{ \"name\": \"{deletedFile}\", \"behavior\":\"assembly\" }}", "");
}

File.WriteAllText(monoConfigFilePath, monoConfig);
Expand Down Expand Up @@ -1322,7 +1322,7 @@ private void RenameFiles(string path, string extension)

private void GetBcl()
{
_bclPath = Path.Combine(MonoWasmSDKPath, "runtimes", "browser-wasm", "lib", "net6.0");
_bclPath = Path.Combine(MonoWasmSDKPath, "runtimes", "browser-wasm", "lib", "net7.0");
var reals = Directory.GetFiles(_bclPath, "*.dll");
_bclAssemblies = reals.ToDictionary(x => Path.GetFileName(x));
}
Expand Down Expand Up @@ -1611,10 +1611,11 @@ private void GenerateConfig()
var enablePWA = !string.IsNullOrEmpty(PWAManifestFile);
var offlineFiles = enablePWA ? string.Join(", ", GetPWACacheableFiles().Select(f => $"\".{f}\"")) : "";

config.AppendLine($"let config = {{}};");
config.AppendLine($"config.uno_remote_managedpath = \"{ Path.GetFileName(_managedPath) }\";");
config.AppendLine($"config.uno_app_base = \"{WebAppBasePath}{_remoteBasePackagePath}\";");
config.AppendLine($"config.uno_dependencies = [{dependencies}];");
config.AppendLine($"config.uno_main = \"[{entryPoint.DeclaringType.Module.Assembly.Name.Name}] {entryPoint.DeclaringType.FullName}:{entryPoint.Name}\";");
config.AppendLine($"config.uno_main = \"{entryPoint.DeclaringType.Module.Assembly.Name.Name}\";");
config.AppendLine($"config.assemblyFileExtension = \"{AssembliesFileExtension}\";");
config.AppendLine($"config.mono_wasm_runtime = \"{monoWasmFileName}\";");
config.AppendLine($"config.mono_wasm_runtime_size = {monoWasmSize};");
Expand Down Expand Up @@ -1663,6 +1664,8 @@ private void GenerateConfig()
AddEnvironmentVariable("UNO_BOOTSTRAP_LOG_PROFILER_OPTIONS", LogProfilerOptions);
}

config.AppendLine("export { config };");

w.Write(config.ToString());
}
}
Expand Down Expand Up @@ -1704,7 +1707,7 @@ private void MergeConfig()

using (var fs = new StreamWriter(tempFile))
{
fs.Write(File.ReadAllText(Path.Combine(_finalPackagePath, "mono-config.js")));
fs.Write(File.ReadAllText(Path.Combine(_finalPackagePath, "mono-config.json")));
fs.Write(File.ReadAllText(Path.Combine(_finalPackagePath, "uno-config.js")));
fs.Write(File.ReadAllText(Path.Combine(_finalPackagePath, "uno-bootstrap.js")));
fs.Write(File.ReadAllText(monoJsPath));
Expand Down
5 changes: 1 addition & 4 deletions src/Uno.Wasm.Bootstrap/Templates/index.html
Expand Up @@ -6,10 +6,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />

<script type="text/javascript" src="./require.js"></script>
<script type="text/javascript" src="./mono-config.js"></script>
<script type="text/javascript" src="./uno-config.js"></script>
<script type="text/javascript" src="./uno-bootstrap.js"></script>
<script async type="text/javascript" src="./dotnet.js"></script>
<script type="module" src="./uno-bootstrap.js"></script>
$(ADDITIONAL_CSS)
$(ADDITIONAL_HEAD)
</head>
Expand Down
28 changes: 27 additions & 1 deletion src/Uno.Wasm.Bootstrap/Uno.Wasm.Bootstrap.csproj
Expand Up @@ -43,6 +43,7 @@
<PackageReference Include="Mono.Options" Version="5.3.0.1" PrivateAssets="All" />
<PackageReference Include="MSBuildTasks" Version="1.5.0.235" PrivateAssets="All" />
<PackageReference Include="System.Text.Json" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="4.5.3" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -123,7 +124,12 @@
</ItemGroup>

<ItemGroup>
<None Remove="build\Uno.Wasm.Bootstrap.props" />
<ConfigFiles Include="tsconfig.json" />
<UpToDateCheckInput Include="ts\**\*" />
</ItemGroup>

<ItemGroup>
<TypeScriptCompile Remove="obj\**\*.ts" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -164,6 +170,26 @@
</ProjectReference>
</ItemGroup>

<!-- Run the typescript compiler before resources resolution -->
<Target Name="GenerateJavascriptBeforeCompile"
BeforeTargets="ResolveProjectReferences"
DependsOnTargets="CompileTypeScriptWithTSConfig">

<!--Delete the log files to avoid the TSC clean target to erase the output files before-->
<ItemGroup>
<TSOutputLogsToDelete Include="$(TSCompilerOutputLogDirectory)Tsc*.out" />
</ItemGroup>

<Delete Files="@(TSOutputLogsToDelete)" />
</Target>

<!-- Include generated javascript as EmbeddedResource -->
<Target Name="IncludeGeneratedJavascript" AfterTargets="CompileTypeScriptWithTSConfig">
<ItemGroup>
<EmbeddedResource Include="@(GeneratedJavascript)" LogicalName="$(AssemblyName).WasmScripts.%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
</Target>

<Target Name="UpdateAdditionalAssemblies" AfterTargets="CoreCompile">
<ItemGroup>
<Content Include="./tools/support/Uno.Wasm.TimezoneData.*">
Expand Down

0 comments on commit e4e5f43

Please sign in to comment.