Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions eng/Version.Details.props
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ This file should be imported by eng/Versions.props
<SystemReflectionMetadataPackageVersion>11.0.0-preview.4.26203.108</SystemReflectionMetadataPackageVersion>
<SystemReflectionMetadataLoadContextPackageVersion>11.0.0-preview.4.26203.108</SystemReflectionMetadataLoadContextPackageVersion>
<SystemTextJsonPackageVersion>11.0.0-preview.4.26203.108</SystemTextJsonPackageVersion>
<!-- dotnet-hotreload-utils dependencies -->
<MicrosoftDotNetHotReloadUtilsGeneratorBuildToolPackageVersion>11.0.0-alpha.0.26173.1</MicrosoftDotNetHotReloadUtilsGeneratorBuildToolPackageVersion>
<!-- dotnet-icu dependencies -->
<MicrosoftNETCoreRuntimeICUTransportPackageVersion>11.0.0-alpha.1.26181.1</MicrosoftNETCoreRuntimeICUTransportPackageVersion>
<!-- dotnet-llvm-project dependencies -->
Expand Down Expand Up @@ -159,8 +157,6 @@ This file should be imported by eng/Versions.props
<SystemReflectionMetadataVersion>$(SystemReflectionMetadataPackageVersion)</SystemReflectionMetadataVersion>
<SystemReflectionMetadataLoadContextVersion>$(SystemReflectionMetadataLoadContextPackageVersion)</SystemReflectionMetadataLoadContextVersion>
<SystemTextJsonVersion>$(SystemTextJsonPackageVersion)</SystemTextJsonVersion>
<!-- dotnet-hotreload-utils dependencies -->
<MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion>$(MicrosoftDotNetHotReloadUtilsGeneratorBuildToolPackageVersion)</MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion>
<!-- dotnet-icu dependencies -->
<MicrosoftNETCoreRuntimeICUTransportVersion>$(MicrosoftNETCoreRuntimeICUTransportPackageVersion)</MicrosoftNETCoreRuntimeICUTransportVersion>
<!-- dotnet-llvm-project dependencies -->
Expand Down
4 changes: 0 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,6 @@
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-optimization</Uri>
<Sha>bc6c6a6b3ae72cfa214ec44b992a60aca978f176</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.HotReload.Utils.Generator.BuildTool" Version="11.0.0-alpha.0.26173.1">
<Uri>https://github.com/dotnet/hotreload-utils</Uri>
<Sha>f5f73b933b5c2a37a4048a49bc2b1a6a0bf2c693</Sha>
</Dependency>
<Dependency Name="System.Runtime.Numerics.TestData" Version="11.0.0-beta.26180.1">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>509fb52c027cd46fab093f10c89691cda982edc4</Sha>
Expand Down
84 changes: 84 additions & 0 deletions eng/testing/hotreload-delta-gen.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->

<!--
Targets for generating hot reload deltas from a delta script.
This replaces the external Microsoft.DotNet.HotReload.Utils.Generator.BuildTool NuGet package.

Projects must define the DeltaScript property that specifies the (relative) path to the json script.
Deltas will be emitted next to the output assembly. Deltas will be copied when the current
project is referenced from other projects.
-->
<Project>

<PropertyGroup>
<DotNetTool Condition="'$(DotNetTool)' == ''">dotnet</DotNetTool>

<_HotReloadDeltaGeneratorToolDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'Microsoft.DotNet.HotReload.Utils.Generator.BuildTool', '$(Configuration)', '$(NetCoreAppToolCurrent)'))</_HotReloadDeltaGeneratorToolDir>

<_HotReloadDeltaGeneratorPath Condition="'$(_HotReloadDeltaGeneratorPath)' == ''">$(_HotReloadDeltaGeneratorToolDir)Microsoft.DotNet.HotReload.Utils.Generator.BuildTool.dll</_HotReloadDeltaGeneratorPath>

<_HotReloadDeltaGeneratorCommand>"$(DotNetTool)" "$(_HotReloadDeltaGeneratorPath)"</_HotReloadDeltaGeneratorCommand>

<_HotReloadDeltaGeneratorTasksDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'Microsoft.DotNet.HotReload.Utils.Generator.Tasks', '$(Configuration)', '$(NetCoreAppToolCurrent)'))</_HotReloadDeltaGeneratorTasksDir>

<_HotReloadDeltaGeneratorTasksPath Condition="'$(_HotReloadDeltaGeneratorTasksPath)' == ''">$(_HotReloadDeltaGeneratorTasksDir)Microsoft.DotNet.HotReload.Utils.Generator.Tasks.dll</_HotReloadDeltaGeneratorTasksPath>
</PropertyGroup>

<PropertyGroup>
<_HotReloadDeltaGeneratorDeltaScript Condition="'$(DeltaScript)' != ''">$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', '$(DeltaScript)'))</_HotReloadDeltaGeneratorDeltaScript>
</PropertyGroup>

<PropertyGroup>
<_HotReloadDeltaGeneratorShouldRun Condition="'$(_HotReloadDeltaGeneratorShouldRun)' == '' and Exists('$(_HotReloadDeltaGeneratorDeltaScript)')">true</_HotReloadDeltaGeneratorShouldRun>
<_HotReloadDeltaGeneratorShouldRun Condition="'$(_HotReloadDeltaGeneratorShouldRun)' == ''">false</_HotReloadDeltaGeneratorShouldRun>
</PropertyGroup>

<UsingTask TaskName="HotReloadDeltaGeneratorComputeScriptOutputs" AssemblyFile="$(_HotReloadDeltaGeneratorTasksPath)" />

<!-- Doesn't actually run the delta generator, but just analyzes the script and figures out what output items it would produce.
Used for computing incremental inputs/outputs of HotReloadDeltaGeneratorGenerateDeltas, and for ContentForDeltaFileOutputNames
-->
<Target Name="HotReloadDeltaGeneratorComputeScriptInputsOutputs"
Condition="'$(_HotReloadDeltaGeneratorShouldRun)' == 'true'">
<HotReloadDeltaGeneratorComputeScriptOutputs BaseAssemblyName="$(TargetPath)" DeltaScript="$(_HotReloadDeltaGeneratorDeltaScript)">
<Output TaskParameter="DeltaOutputs" ItemName="_HotReloadDeltaGeneratorOutputs" />
<Output TaskParameter="DeltaSources" ItemName="_HotReloadDeltaGeneratorInputs" />
</HotReloadDeltaGeneratorComputeScriptOutputs>
Comment thread
akoeplinger marked this conversation as resolved.
</Target>

<!-- Invoke hotreload-delta-gen to apply the DeltaScript to the output assembly to
create the .dmeta, .dil and .dpdb files on the OutputPath -->
<Target Name="HotReloadDeltaGeneratorGenerateDeltas"
AfterTargets="Build"
DependsOnTargets="HotReloadDeltaGeneratorComputeScriptInputsOutputs"
Condition="'$(_HotReloadDeltaGeneratorShouldRun)' == 'true'"
Inputs="$(TargetPath); @(_HotReloadDeltaGeneratorInputs)"
Outputs="@(_HotReloadDeltaGeneratorOutputs)"
>
<PropertyGroup>
<_HotReloadDeltaGeneratorArgs>"-msbuild:$(MSBuildProjectFullPath)"</_HotReloadDeltaGeneratorArgs>
<_HotReloadDeltaGeneratorArgs>$(_HotReloadDeltaGeneratorArgs) "-script:$(_HotReloadDeltaGeneratorDeltaScript)"</_HotReloadDeltaGeneratorArgs>

<!-- This is a little bit delicate: we're invoking a design-time msbuild here, and we need it to come back with the same OutputPath as the current
run of msbuild. If there are other properties that affect where the baseline assembly ends up, we need to pass those here too.
-->
<_HotReloadDeltaGeneratorArgs Condition="'$(Configuration)' != ''">$(_HotReloadDeltaGeneratorArgs) -p:Configuration=$(Configuration)</_HotReloadDeltaGeneratorArgs>
<_HotReloadDeltaGeneratorArgs Condition="'$(RuntimeIdentifier)' != ''">$(_HotReloadDeltaGeneratorArgs) -p:RuntimeIdentifier=$(RuntimeIdentifier)</_HotReloadDeltaGeneratorArgs>
<!-- escape hatch for any extra arguments -->
<_HotReloadDeltaGeneratorArgs Condition="'$(HotReloadDeltaGeneratorExtraArgs)' != ''">$(_HotReloadDeltaGeneratorArgs) $(HotReloadDeltaGeneratorExtraArgs)</_HotReloadDeltaGeneratorArgs>
</PropertyGroup>
<Exec Command="$(_HotReloadDeltaGeneratorCommand) $(_HotReloadDeltaGeneratorArgs)" />
</Target>

<Target Name="HotReloadDeltaGeneratorContentForOutputs"
BeforeTargets="AssignTargetPaths"
DependsOnTargets="HotReloadDeltaGeneratorComputeScriptInputsOutputs"
Condition="'$(_HotReloadDeltaGeneratorShouldRun)' == 'true' and '$(DesignTimeBuild)' != 'true'">
<ItemGroup>
<Content Include="@(_HotReloadDeltaGeneratorOutputs)">
<CopyToOutputDirectory>always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
<Project>
<Import Project="..\..\Directory.Build.props" />

<ItemGroup>
<!-- This package from https://github.com/dotnet/hotreload-utils provides
targets that read the json delta script and generates deltas based on the baseline assembly and the modified sources.

Projects must define the DeltaScript property that specifies the (relative) path to the json script.
Deltas will be emitted next to the output assembly. Deltas will be copied when the current
project is referenced from other other projects.
-->
<PackageReference Include="Microsoft.DotNet.HotReload.Utils.Generator.BuildTool" Version="$(MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion)" />
</ItemGroup>

<PropertyGroup>
<!-- to call AsssemblyExtensions.ApplyUpdate we need Optimize=false, EmitDebugInformation=true in all configurations -->
<Optimize>false</Optimize>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<Project>
<Import Project="..\..\..\Directory.Build.targets" />
<Import Project="$(RepositoryEngineeringDir)testing\hotreload-delta-gen.targets" />
</Project>
4 changes: 4 additions & 0 deletions src/libraries/pretest.proj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<!-- Task for building the PlatformManifest and the sfx deps.json -->
<ProjectReference Include="$(RepoTasksDir)installer.tasks\installer.tasks.csproj" Condition="'$(BuildTargetFramework)' == '$(NetCoreAppCurrent)' or '$(BuildTargetFramework)' == ''" />

<!-- Hot reload delta generator tool, used by ApplyUpdate test projects -->
<ProjectReference Include="$(ToolsProjectRoot)hotreload-delta-gen\Microsoft.DotNet.HotReload.Utils.Generator.BuildTool\Microsoft.DotNet.HotReload.Utils.Generator.BuildTool.csproj" />
<ProjectReference Include="$(ToolsProjectRoot)hotreload-delta-gen\Microsoft.DotNet.HotReload.Utils.Generator.Tasks\Microsoft.DotNet.HotReload.Utils.Generator.Tasks.csproj" />

<!-- HelixTestTasks for batched WASM library tests on Helix -->
<ProjectReference Include="$(RepoTasksDir)HelixTestTasks\HelixTestTasks.csproj" Condition="'$(TargetOS)' == 'browser'" />

Expand Down
13 changes: 5 additions & 8 deletions src/mono/sample/mbr/console/ConsoleDelta.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@
<ProjectReference Include="..\DeltaHelper\DeltaHelper.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.DotNet.HotReload.Utils.Generator.BuildTool" Version="$(MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion)" />
</ItemGroup>
<PropertyGroup>
<DeltaScript>deltascript.json</DeltaScript>
</PropertyGroup>

<Import Project="$(RepositoryEngineeringDir)testing\hotreload-delta-gen.targets" />

<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="TestClass.cs" />
</ItemGroup>


<PropertyGroup>
<DeltaScript>deltascript.json</DeltaScript>
</PropertyGroup>

<PropertyGroup Condition="'$(BuiltRuntimeConfiguration)' != ''">
<HotReloadDeltaGeneratorExtraArgs>$(HotReloadDeltaGeneratorExtraArgs) -p:BuiltRuntimeConfiguration=$(BuiltRuntimeConfiguration)</HotReloadDeltaGeneratorExtraArgs>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@
</ItemGroup>

<!-- ActiveIssue https://github.com/dotnet/runtime/issues/114526 deadlocks on linux CI -->
<ItemGroup Condition="'$(OS)' == 'Windows_NT' or '$(ContinuousIntegrationBuild)' != 'true'">
<!-- This package from https://github.com/dotnet/hotreload-utils provides
targets that read the json delta script and generates deltas based on the baseline assembly and the modified sources.

Projects must define the DeltaScript property that specifies the (relative) path to the json script.
Deltas will be emitted next to the output assembly. Deltas will be copied when the current
project is referenced from other other projects.
-->
<PackageReference Include="Microsoft.DotNet.HotReload.Utils.Generator.BuildTool" Version="$(MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion)" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)testing\hotreload-delta-gen.targets"
Condition="'$(OS)' == 'Windows_NT' or '$(ContinuousIntegrationBuild)' != 'true'" />
</Project>
28 changes: 28 additions & 0 deletions src/tools/hotreload-delta-gen/Common/TempDirectory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.IO;

namespace Microsoft.DotNet.HotReload.Utils.Common;

internal class TempDirectory : IDisposable
{
public TempDirectory(bool keep = false, string? dirname = null)
{
string subdir = dirname ?? System.IO.Path.GetRandomFileName();
Path = System.IO.Path.Combine(System.IO.Path.GetTempPath(), subdir);
Keep = keep;
Directory.CreateDirectory(Path);
}

public string Path { get; }
public bool Keep { get; set; }

public void Dispose()
{
if (!Keep)
Directory.Delete(Path, true);
GC.SuppressFinalize(this);
}
}
17 changes: 17 additions & 0 deletions src/tools/hotreload-delta-gen/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project>
<Import Project="..\Directory.Build.props" />

<PropertyGroup>
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>Latest</LangVersion>
<SlnGenSolutionFolder>tools\hotreload-delta-gen\</SlnGenSolutionFolder>
<IsShipping>false</IsShipping>

Comment thread
akoeplinger marked this conversation as resolved.
<!--
This code was imported from https://github.com/dotnet/hotreload-utils which did not
enforce runtime's strict analyzer rules. Suppress analyzer warnings-as-errors for now.
-->
<RunAnalyzers>false</RunAnalyzers>
</PropertyGroup>
</Project>
3 changes: 3 additions & 0 deletions src/tools/hotreload-delta-gen/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project="..\Directory.Build.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<RollForward>Major</RollForward>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.DotNet.HotReload.Utils.Generator.Frontend\Microsoft.DotNet.HotReload.Utils.Generator.Frontend.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

return Microsoft.DotNet.HotReload.Utils.Generator.Frontend.Frontend.Main(args);
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Microsoft.DotNet.HotReload.Utils.Generator.BuildTool #

Generate deltas as part of an MSBuild project.

## How to use it ##

Starting with an existing SDK-style project, add:

```xml
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.HotReload.Utils.Generator.BuildTool" Version="..." />
</ItemGroup>

<PropertyGroup>
<DeltaScript>deltascript.json</DeltaScript>
</PropertyGroup>
```

Where the `deltascript.json` file contains the changes to be applied:

```json
{"changes":
[
{"document": "relativePath/to/file.cs", "update": "relativePath/to/file_v1.cs"},
{"document": "file2.cs", "update": "file2_v2.cs"},
{"document": "relativePath/to/file.cs", "update": "relativePath/to/file_v3.cs"}
]
}
```

The tool will run as part of the build after the `Build` target and generate `.dmeta`, `.dil` and `.dpdb` files in `$(OutputPath)`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<Project Sdk="Microsoft.NET.Sdk">
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text.Json.Serialization;


namespace Microsoft.DotNet.HotReload.Utils.Generator.OutputSummary;

public class OutputSummary {
[JsonPropertyName("deltas")]
public Delta[]? Deltas {get; init;}

[JsonExtensionData]
public System.Collections.Generic.Dictionary<string, object>? Extra {get; init;}

[JsonConstructor]
public OutputSummary(Delta[]? deltas) {
Deltas = deltas;
}
}

public class Delta {
[JsonPropertyName("assembly")]
public string? Assembly {get; init;}
[JsonPropertyName("metadata")]
public string? Metadata {get; init;}
[JsonPropertyName("il")]
public string? IL {get; init;}
[JsonPropertyName("pdb")]
public string? Pdb {get; init;}

[JsonConstructor]
public Delta (string? assembly, string? metadata, string? il, string? pdb) {
Assembly = assembly;
Metadata = metadata;
IL = il;
Pdb = pdb;
}

[JsonExtensionData]
public System.Collections.Generic.Dictionary<string, object>? Extra {get; set;}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text.Json.Serialization;

namespace Microsoft.DotNet.HotReload.Utils.Generator.Script.Json;
public class Script {

[JsonConverter(typeof(ScriptCapabilitiesConverter))]
public string? Capabilities {get; init;}
public Change[]? Changes {get; init;}

[System.Text.Json.Serialization.JsonConstructor]
public Script (string? capabilities, Change[]? changes) {
Capabilities = capabilities;
Changes = changes;
}

}

public class Change {
public string Document {get; init;}
public string Update {get; init;}

[System.Text.Json.Serialization.JsonConstructor]
public Change (string document, string update) {
Document = document;
Update = update;
}
}
Loading
Loading