dotnet / dotnet/project-system

Framework references not populated if called using the DTE

Open
#1,826 5 comments 0 reactions 0 assignees View on GitHub
Parity-Legacy-API Parity-Legacy-Feature Triage-Approved
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

1. Create a csproj that targets `net461` like so:
```


net461

```
2. Attempt to add an assembly reference using the DTE
```C#
string assemblyName = "WindowsBase";
var vsproject = ((VSProject)project.Object);
vsproject.References.Add(assemblyName);
```

**Expected**:
the `WindowsBase` reference is resolved and added to the project.

**Actual**:
```
System.ArgumentException : Unable to find a type of reference that is appropriate for this file: "WindowsBase".

Server stack trace:
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAVSReferences.Add(String bstrPath)
at Microsoft.VisualStudio.IntegrationTest.Utilities.InProcess.SolutionExplorer_InProc.AddMetadataReference(String assemblyName, String projectName)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
```

**Notes**:
This scenario works in the Reference Manager because we appear to populate the Framework references asynchronously on demand.
![image](https://cloud.githubusercontent.com/assets/9797472/24218481/bb70aa7c-0f00-11e7-8733-5e22b2e39049.png)

If the Framework references are populated by the Reference Manager first, subsequent calls to `vsproject.References.Add(assemblyName)` will succeed in finding the framework reference. It seems we need to add some logic ensure that this code path also causes the Framework references to be populated.

This is blocking integration tests.

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.