2

"...\System.Runtime.WindowsRuntime.dll" in item list "ReferencePath" does not define a value for metadata "CopyLocal". In order to use this metadata, either qualify it by specifying %(ReferencePath.CopyLocal), or ensure that all items in this list define a value for this metadata.

I'm unable to build WinForms app after adding WebView copomenent to it due to above error. I've found possible solutions like migrate package.config to PackageReference or adding CopyLocal to C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets file. None of them works for me.

System.Runtime.WindowsRuntime.targets file in the project look like this:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Choose>
    <When Condition="'$(DoNotReferenceWinRT)' != 'true'">
      <!-- 
        ResolveAssemblyReference was attempting to write binding redirects
        for these assemblies (even though they are in the unification list).
      -->
      <PropertyGroup>
        <!-- ...include the reference to System.Runtime -->
        <DependsOnNETStandard>true</DependsOnNETStandard>
      </PropertyGroup>
      <ItemGroup>
        <ReferencePath Include="$(MSBuildThisFileDirectory)..\..\ref\netstandard2.0\System.Runtime.WindowsRuntime.dll">
          <!-- Private = false to make these reference only -->
          <Private>false</Private>
          <!-- given this package does not have NugetPackage metadata it will not show in solution explorer, making it explicit -->
          <Visible>false</Visible>
        </ReferencePath>
      </ItemGroup>
    </When>
  </Choose>
  <!-- when this package is referenced as a nuget reference the binding redirect is still present, add a target to remove it -->
  <Target Name="_RemoveWindowsRuntimeSuggestedRedirect" 
      BeforeTargets="GenerateBindingRedirects" 
      DependsOnTargets="ResolveAssemblyReferences"
      Condition="'$(DoNotReferenceWinRT)' != 'true'">
    <ItemGroup> 
      <SuggestedBindingRedirects Remove="System.Runtime.WindowsRuntime, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
    </ItemGroup> 
  </Target>
</Project>

I'm using latest Visual Studio 2019 Professional.

  • remove `true` – T.S. Jun 20 '20 at 05:12
  • it was actually added by me but it changes nothing – Charles C Bonham Jun 20 '20 at 12:26
  • Please refer to the similar issue [Upgrading WebBrowser class into WebView class in winforms application](https://stackoverflow.com/questions/59269515/upgrading-webbrowser-class-into-webview-class-in-winforms-application) to check if it can solve your problem. – Jack J Jun Jun 22 '20 at 08:37

0 Answers0