![Quality Gate Status](https://camo.githubusercontent.com/78ee4ad9d1fcbf9549de0dd2389817fe42be0f2eafbb72966ac72790a8fd83ad/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d30557365724e616d655f4e754765745377697463686572266d65747269633d616c6572745f737461747573)
For the extension to work, you need to specify a configuration file that essentially only contains paths (one per line) for searching for projects:
![ext_options](https://user-images.githubusercontent.com/46850587/148584567-ad3d5b06-1a70-486c-9b20-f23ad4b554d4.png)
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.
![ext_sln_explorer](https://user-images.githubusercontent.com/46850587/148584494-a64ccc6d-864c-4267-bdc1-e1ab58995b33.png)
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:
![ext_error_list](https://user-images.githubusercontent.com/46850587/148586028-5ed93be8-8ab5-4256-9f00-10af0507e4cd.png)
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>
Comments
Separate lines entered in the configuration file can be commented out as follows:
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.