Dhawalk
Dhawalk

Reputation: 1269

VS shows References that are not in csproj file

I am trying to compile WebView for embedding Edge in WPF (Microsoft.Toolkit.Wpf.UI.Controls.WebView). Its available on Git at https://github.com/windows-toolkit/WindowsCommunityToolkit

The csproj has no reference to "Windows", but Visual Studio shows that its a missing reference. not sure how to resolve this. any help is appreciated. I get an error when removing "Windows" Reference - "Cannot modify an evaluated object originating in an imported file"

enter image description here

Upvotes: 0

Views: 1229

Answers (3)

Zhi Lv
Zhi Lv

Reputation: 21383

I am trying to compile WebView for embedding Edge in WPF

Please refer to the following article to install the Microsoft.Toolkit.Forms.UI.Controls.WebView package and using the WebView control in a WPF application.

WebView control for Windows Forms and WPF

Upvotes: 0

Dhawalk
Dhawalk

Reputation: 1269

The reference was getting added from Directory.Build.targets file. it had the following condition that was adding the reference

<Choose>
    <When Condition="'$(IsWin32Project)' == 'true' or '$(IsWpfProject)' == 'true' or '$(IsFormsProject)' == 'true'">
      <PropertyGroup>
        <TargetPlatformVersion Condition="'$(TargetPlatformVersion)' == ''">10.0.$(DefaultTargetPlatformVersion).0</TargetPlatformVersion>
        <TargetPlatformMinVersion Condition="'$(TargetPlatformMinVersion)' == ''">10.0.$(DefaultTargetPlatformMinVersion).0</TargetPlatformMinVersion>
      </PropertyGroup>
      <ItemGroup>
        <Reference Include="Windows">
          <HintPath Condition="Exists('$(MSBuildProgramFiles32)\Windows Kits\10\UnionMetadata\$(TargetPlatformMinVersion)\Windows.winmd')">$(MSBuildProgramFiles32)\Windows Kits\10\UnionMetadata\$(TargetPlatformMinVersion)\Windows.winmd</HintPath>
          <HintPath Condition="Exists('$(MSBuildProgramFiles32)\Windows Kits\10\UnionMetadata\$(TargetPlatformVersion)\Windows.winmd')">$(MSBuildProgramFiles32)\Windows Kits\10\UnionMetadata\$(TargetPlatformVersion)\Windows.winmd</HintPath>
          <Private>False</Private>
        </Reference>
      </ItemGroup>
    </When>
  </Choose>

Upvotes: 1

Guybrush Threepwood
Guybrush Threepwood

Reputation: 1266

Right-click on the reference and then remove it. Once it's done you can then go to Build and then clean, then rebuild the solution.

Upvotes: 1

Related Questions