Skip to content

Commit

Permalink
Enable Source Link
Browse files Browse the repository at this point in the history
I'm not exactly publishing a big Nuget package that anyone cares about, but the .NET 8 SDK defaults to adding source control information (namely the commit hash) to assemblies, and it wasn't much more to turn on the full set of features. We'll see how this goes.
  • Loading branch information
ItEndsWithTens committed Feb 22, 2024
1 parent b2d15f1 commit c4d5dfe
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
9 changes: 7 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@
<BaseOutputPath>$(ArtifactsDir)\bin\$(MSBuildProjectName)\</BaseOutputPath>

<PlatformTarget>AnyCPU</PlatformTarget>
<Deterministic>true</Deterministic>
<MacBuildBundle>true</MacBuildBundle>
<MacBundleName>$(Product)</MacBundleName>
<MacBundleMono>false</MacBundleMono>

<!--Taken together, these properties allow Source Link to provide embedded
debug information that's tied to public source files hosted on Github,
allowing convenient debugging even without local copies of the code. Note
that ContinuousIntegrationBuild may be overridden by the SetCIBuild task.-->
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DebugType>embedded</DebugType>
<Deterministic>true</Deterministic>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'" >true</ContinuousIntegrationBuild>

<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest-AllEnabledByDefault</AnalysisLevel>
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
## Development

Be careful using C# features introduced beyond version 7.3!

This project uses C# language version 10.0 despite running under .NET Framework 4.8, a combination which is not officially supported. Newer versions of the language introduce some features that require new types and/or an updated runtime, but there are nonetheless many purely syntactical improvements that prove exceptionally useful, and are too good to ignore.

For more information see [Microsoft's documentation](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version), [StackOverflow](https://stackoverflow.com/questions/56651472/does-c-sharp-8-support-the-net-framework), and [this blog post by Stuart Lang](https://stu.dev/csharp8-doing-unsupported-things/).
Expand All @@ -66,11 +66,11 @@
- `cd ..\..\..`
- `dotnet build -c:Release`

4. Optionally, create the distribution zip file.
4. Optionally, create the distribution zip file. Keep in mind that the CreateZip build target strips local file path information out of the embedded debug symbols, so this step is only useful for distributable builds, not local development and debugging.
- `dotnet build src\SHME.ExternalTool\SHME.ExternalTool.csproj -c:Release -t:CreateZip`

Drill down into the artifacts directory to find the DLL, and copy it into your BizHawk\ExternalTools directory. The tool should then be available in BizHawk, provided you've loaded a disc image of Silent Hill that matches the expected hash.

For easy debugging in Visual Studio, open the external tool project's properties and create a new Executable debug launch profile as follows:

- Executable: `.\EmuHawk.exe`
Expand All @@ -79,6 +79,8 @@

You'll be up and running with a single keypress, and working on the plugin should then be vastly more convenient. Have fun!

In event of any problems, try cleaning the solution and rebuilding just in case, and don't forget about dotnet build's `-bl` option that spits out a binary log. With one in hand, head over to https://msbuildlog.com/ and save yourself a lifetime of build debugging anguish.



### Benchmarking
Expand Down
23 changes: 21 additions & 2 deletions src/SHME.ExternalTool/SHME.ExternalTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />

<Reference Include="BizHawk.Bizware.BizwareGL" HintPath="$(BizHawkOutputDir)\dll\BizHawk.Bizware.BizwareGL.dll" />
Expand Down Expand Up @@ -48,15 +52,30 @@

<Target Name="InstallInEmulator" AfterTargets="PostBuildEvent">
<Copy SourceFiles="$(OutputPath)\$(MSBuildProjectName).dll" DestinationFolder="$(BizHawkOutputDir)\ExternalTools" />
<Copy SourceFiles="$(OutputPath)\$(MSBuildProjectName).pdb" DestinationFolder="$(BizHawkOutputDir)\ExternalTools" />
</Target>

<PropertyGroup>
<DistDir>$(ArtifactsDir)\dist\</DistDir>
<PrepDir>$(DistDir)\prep\</PrepDir>
</PropertyGroup>

<Target Name="CreateZip" DependsOnTargets="Build">
<!--When running the CreateZip target to produce the distribution archive,
it's only sensible to strip local file path information out of the embedded
debug symbols even if the build happens to be running on a developer's local
machine. A dedicated target that CreateZip depends on handles that with,
admittedly, some fuss.-->
<Target Name="SetCIBuild" BeforeTargets="Build">
<PropertyGroup>
<!--ContinuousIntegrationBuild, when set true as a property directly in a
project, sets DeterministicSourcePaths true as well. Unfortunately, for
the time being updating the value of the former while in a target fails to
also update the value of the latter. Doing it manually seems to work.-->
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<DeterministicSourcePaths>true</DeterministicSourcePaths>
</PropertyGroup>
</Target>

<Target Name="CreateZip" DependsOnTargets="SetCIBuild;Build">
<RemoveDir Directories="$(PrepDir)" />
<Copy SourceFiles="$(OutputPath)\$(MSBuildProjectName).dll" DestinationFolder="$(PrepDir)" />
<Copy SourceFiles="$(TopLevelDirectory)\README.md" DestinationFiles="$(PrepDir)\$(MSBuildProjectName).txt" />
Expand Down

0 comments on commit c4d5dfe

Please sign in to comment.