For the extension to work, you need to specify a configuration file that essentially only contains paths (one per line) for searching for projects:
When you click the
Use ProjectReference
button, the extension looks through the list of projects included in the solution and begins to process each of them sequentially.
Project dependency search is based on
project.assets.json
file, which lists all the dependencies of the project. It is created in the /obj folder when using dotnet restore
or dotnet build
as it implicitly calls restore before build, or msbuid.exe /t:restore
with MSBuild CLI. If project.assets.json
is not found in the specified project directory, then the extension stops processing and displays the following message:
If the file is present, then the extension starts processing explicit and implicit (transitive) dependencies of the project - NuGet packages, framework assemblies. After processing, the Messages tab of the Error List displays information about each changed project and the references included in it.
When working with references, only evaluated items are used. In this example, when using the Debug configuration, reference A will be replaced, while for the Release configuration, reference B.
<Choose>
<When Condition=" '$(Configuration)' != 'Release' ">
<ItemGroup>
<PackageReference Include="LibraryA" Version="0.1.0*" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<ProjectReference Include="LibraryB" Version="0.1.0*" />
</ItemGroup>
</Otherwise>
</Choose>
Multitargeting as such does not have special support, i.e. a project with
TFMs
defined as follows:
<TargetFrameworks>
net461;net462;net472;netstandard2.0;netstandard2.1
</TargetFrameworks>
Will be processed as if it had
TFMs
:
<TargetFrameworkVersion>
v4.6.1
</TargetFrameworkVersion>
Separate lines entered in the configuration file can be commented out as follows:
#E:\Project\a\Library
With this configuration, at the moment of switching references, the search for in the commented out directories will be ignored.
It is assumed that in the stable version the extension should support Visual Studio 22. The author conducted an initial test in the next version of Visual Studio:
Microsoft Visual Studio Community 2022
Version 17.2.5
.NET Core SDK version >= 3.0 is required since version 0.5.0.