visual-studionugetdocfx

How to turn off DocFX build each time i rebuild project in Visual Studio [2019] [NuGet]


I tried to start using DocFX and it meets my requirements, but I have a minor problem that is quite bothersome in the long run.

Every time I change something in the project and enable debugging, the DocFX's nuget adapts to the new changes.

This is correct behavior, but I would like to be able to turn this off for some time. It doesn't take long, but due to frequent changes it significantly extends the time to test anything.

I was looking in user Manual: https://dotnet.github.io/docfx/tutorial/docfx.exe_user_manual.html and I tried to do it on my own, but I didn't find any way to do that except to throw the nuget out of the project.


Solution

  • How to turn off DocFX build each time i rebuild project in Visual Studio [2019] [NuGet]

    This is the feature of the nuget package docfx.console and I suggest you could turn off this nuget package temporarily by this way:

    Use a new configuration which removes the docfx nuget package to test it.

    1) add a new configuration called test

    enter image description here

    2) If it is a net framework project with packages.config, you should

    change this in xxx.csproj file:

    <Import Project="..\packages\docfx.console.2.55.0\build\docfx.console.targets" Condition="Exists('..\packages\docfx.console.2.55.0\build\docfx.console.targets')/>
    

    to

     <Import Project="..\packages\docfx.console.2.55.0\build\docfx.console.targets" Condition="Exists('..\packages\docfx.console.2.55.0\build\docfx.console.targets') and '$(Configuration)'!='Test'" />
    

    Then, you can switch the configuration as you want to get your goal.

    The Test Configuration will not consume the package and other configuration will consume it.

    =========================

    If it is a net project with PackageReference, you should add <ExcludeAssets>buildtransitive</ExcludeAssets> under PackageReference node to prevent consumption of the target files of the packageļ¼š

    Like this:

    <ItemGroup>
            <PackageReference Include="docfx.console" >
                <Version>2.55.0</Version>
                <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
                <PrivateAssets>all</PrivateAssets>
                <ExcludeAssets>buildtransitive</ExcludeAssets>
            </PackageReference>
        </ItemGroup>