dotnet / dotnet/project-system

Adding an assembly reference via CPS does not update Roslyn MetadataReferences.

Open
#4,636 10 comments 0 reactions 0 assignees View on GitHub
Triage-Approved
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

**Version Used**:
2.9.0

**Steps to Reproduce**:

1. Open a solution with a C# project.
2. Obtain a `ConfiguredProject` interface for the C# project.
3. Add a reference to a GAC'd assembly via the following calls:
```
await configuredProject.Services.AssemblyReferences.AddAsync(assemblyName, null);

await configuredProject.UnconfiguredProject.SaveAsync();
```
4. Note that the `.csproj` file is properly updated to include the reference.
5. Obtain a reference to the `VisualStudioWorkspace` and locate the `Project` to which the reference was added.
6. Note that the `MetadataReferences` on that `Project` do NOT include the reference added via the CPS calls above.

**Expected Behavior**:
The Roslyn project should pick up the added reference.

**Actual Behavior**:
The Roslyn project does not include the added reference.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.