Skip to content

NuGetReferenceSwitcher not reverting Project files back to their original state (VS 2017) #33

@KwalityKoder

Description

@KwalityKoder

Within a Project, if I use NuGetReferenceSwitcher to switch from a NuGet to a Project Reference for NuGet Package X, and then use NuGetReferenceSwitcher to revert back to the NuGet reference, the .csproj file has an extra line added immediately following the <ItemGroup> ,<Reference Include="X"> nodes as follows:

<SpecificVersion>False</SpecificVersion>

I would expect the csproj file to remain completely unchanged after reverting back to the original NuGet package reference.


Coding fix was to modify ProjectModel.AddReference() to reset the SpecificVersion flag to true.

                // ReSharper disable once SuspiciousTypeConversion.Global
                if (_vsProject.References.Add(assemblyPath) is Reference4 reference)
                {
                    reference.SpecificVersion = true;
                }

where Reference4 is a new Interface I created following the instructions here

Setting the properties of a reference programmatically

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions