Skip to content

Adding a dependency to an external (dotnet) repo

Adam Yoblick edited this page Aug 15, 2019 · 4 revisions

I recently got an error message when building the winforms repo that looked like this:

C:\Program Files (x86)\Microsoft Visual Studio\2019\IntPreview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(3056,5): error : MSB3822: Non-string resources require the System.Resources.Extensions assembly at runtime, but it was not found in this project's references. [E:\src\repos\github\winforms\src\System.Windows.Forms\src\System.Windows.Forms.csproj]

Here are the steps I did to add this dependency to our repo:

  1. I added a package reference to System.Resources.Extensions with the version set to a variable that was not yet defined.
	<PackageReference Include="System.Resources.Extensions" Version="$(SystemResourcesExtensionsPackageVersion)" />
  1. Now I had to find where this package comes from.

  2. Now I needed a package version

    • I noticed that all the other packages we consume from corefx have the same version (currently 4.6.0-preview9.19409.17), which means it has the same commit Sha.
  3. I had what I needed, so I added the following to Version.Details.xml:

    <Dependency Name="System.Resources.Extensions" Version="4.6.0-preview9.19409.17" CoherentParentDependency="Microsoft.NETCore.App">
      <Uri>https://github.com/dotnet/corefx</Uri>
      <Sha>b82d2bc44424c8a99a1f0fc13202bdfd43e6f9f5</Sha>
    </Dependency>
  1. And I added the following to Versions.props:
<SystemResourcesExtensionsPackageVersion>4.6.0-preview9.19409.17</SystemResourcesExtensionsPackageVersion>
* Note that the Xml element name in Versions.props needs to match the dependency name from Version.Details.xml, with the periods removed, and with “PackageVersion” appended at the end.
  1. Run .\build from the repo root to perform a restore and the package reference will resolve correctly :)