Skip to content

Instantly share code, notes, and snippets.

@Sebazzz
Created April 14, 2019 07:54
Show Gist options
  • Save Sebazzz/67c91b04a43531c85ffb4b58b22006e7 to your computer and use it in GitHub Desktop.
Save Sebazzz/67c91b04a43531c85ffb4b58b22006e7 to your computer and use it in GitHub Desktop.
ASP.NET Core 2.2.0 - Build locally and use locally build debug binaries in .NET Core

It is a bit complicated to build the binaries and use the locally because the shared framework makes it all very compiled.

Anyway, here goes:

  1. Check out the AspNetCore repository recursively (so that the sub modules are checked out as well).

  2. Apply the diff from this gist.

  3. Run the build: .\build.cmd /t:BuildSharedFx /p:SkipTests=true /p:DisableCodeSigning=true /p:DisableSignCheck=true

  4. Now it gets messy. You'il have a build/artifacts/installer folder with a zip file. Expand this zip file in %PROGRAMFILES%\dotnet\shared\Microsoft.AspNetCore.App\<version of your framework build>. These are not the good binaries however because there are nowhere the correct symbol files to be found. For the packages you wish to debug, you need to extract the dll and symbol files from the *.symbols.nupkg files and overwrite them in the shared framework folder path.

  5. Finally, modify your project file. Add <NoWarn>NU1603;NU1605;NU5125;$(NoWarn)</NoWarn> and use a PackageReference with a version number equal to the <version of your framework build>. Delete the obj folder and run a dotnet restore.

diff --git "a/build/SharedFx.targets" "b/build/SharedFx.targets"
index 016a08afb1..7905a0e30f 100644
--- "a/build/SharedFx.targets"
+++ "b/build/SharedFx.targets"
@@ -6,6 +6,8 @@
<BuildSharedFxDependsOn>_BuildSharedFxProjects;TestSharedFx</BuildSharedFxDependsOn>
<BuildSharedFxDependsOn Condition="'$(TestOnly)' != 'true'">$(BuildSharedFxDependsOn);CodeSign</BuildSharedFxDependsOn>
<RedistNetCorePath>$(IntermediateDir)ar\$(SharedFxRid)\</RedistNetCorePath>
+
+ <NoWarn>NU1603;NU1605;NU5125;$(NoWarn)</NoWarn>
</PropertyGroup>
<ItemGroup>
@@ -54,15 +56,15 @@
<MSBuild Projects="$(MSBuildToolsPath)\NuGet.targets"
Targets="Restore"
- Properties="$(SharedFxBuildProperties);RestoreGraphProjectInput=$(_RestoreGraphProjectInput);_DummyTarget=Restore" />
+ Properties="$(SharedFxBuildProperties);RestoreGraphProjectInput=$(_RestoreGraphProjectInput);_DummyTarget=Restore;NoWarn=$(NoWarn)" />
<MSBuild Projects="@(ProjectToBuild)"
- Properties="$(SharedFxBuildProperties)"
+ Properties="$(SharedFxBuildProperties);NoWarn=$(NoWarn)"
BuildInParallel="true" />
<MSBuild Projects="@(ProjectToBuild)"
Targets="Pack"
- Properties="$(SharedFxBuildProperties);NoBuild=true"
+ Properties="$(SharedFxBuildProperties);NoBuild=true;NoWarn=$(NoWarn)"
BuildInParallel="true"
SkipNonexistentTargets="true" />
</Target>
@westfin
Copy link

westfin commented Jan 14, 2020

If I correctly understand full pipeline of build target BuildSharedFx it not build Microsoft.AspNetCore.App from source it just download all dependencies from nuget storage.
If it is correctly, can we build shared framework from sources in this repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment