Skip to content

Commit

Permalink
feat(nuget): add support for centralized PackageVersion (renovatebot#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dobrou committed Nov 1, 2020
1 parent c2ebd71 commit cdaf3e9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/usage/nuget.md
Expand Up @@ -20,7 +20,7 @@ To convert your .NET Framework `.csproj`/`.fsproj`/`.vbproj` into an SDK-style p
## How It Works

1. Renovate will search each repository for any files with a `.csproj`, `.fsproj`, or `.vbproj` extension.
2. Existing dependencies will be extracted from `<PackageReference>` tags
2. Existing dependencies will be extracted from `<PackageReference>` and `<PackageVersion>` tags
3. Renovate will look up the latest version on [nuget.org](https://nuget.org) (or on [alternate feeds](#Alternate%20feeds)) to determine if any upgrades are available
4. If the source package includes a GitHub URL as its source, and has either a "changelog" file or uses GitHub releases, then Release Notes for each version will be embedded in the generated PR.

Expand Down
@@ -0,0 +1,5 @@
<Project>
<ItemGroup>
<PackageVersion Include="Autofac" Version="4.5.0" />
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions lib/manager/nuget/__snapshots__/extract.spec.ts.snap
Expand Up @@ -183,6 +183,17 @@ Array [
]
`;

exports[`lib/manager/nuget/extract extractPackageFile() extracts package version dependency 1`] = `
Array [
Object {
"currentValue": "4.5.0",
"datasource": "nuget",
"depName": "Autofac",
"depType": "nuget",
},
]
`;

exports[`lib/manager/nuget/extract extractPackageFile() extracts registry URLs independently 1`] = `
Object {
"deps": Array [
Expand Down
10 changes: 10 additions & 0 deletions lib/manager/nuget/extract.spec.ts
Expand Up @@ -16,6 +16,16 @@ describe('lib/manager/nuget/extract', () => {
await extractPackageFile('nothing here', 'bogus', config)
).toMatchSnapshot();
});
it('extracts package version dependency', async () => {
const packageFile =
'with-centralized-package-versions/Directory.Packages.props';
const sample = readFileSync(
path.join(config.localDir, packageFile),
'utf8'
);
const res = await extractPackageFile(sample, packageFile, config);
expect(res.deps).toMatchSnapshot();
});
it('extracts all dependencies', async () => {
const packageFile = 'sample.csproj';
const sample = readFileSync(
Expand Down
1 change: 1 addition & 0 deletions lib/manager/nuget/extract.ts
Expand Up @@ -27,6 +27,7 @@ function extractDepsFromXml(xmlNode: XmlDocument): PackageDependency[] {
for (const itemGroup of itemGroups) {
const relevantChildren = [
...itemGroup.childrenNamed('PackageReference'),
...itemGroup.childrenNamed('PackageVersion'),
...itemGroup.childrenNamed('DotNetCliToolReference'),
...itemGroup.childrenNamed('GlobalPackageReference'),
];
Expand Down

0 comments on commit cdaf3e9

Please sign in to comment.