feat(nuget): add support for centralized PackageVersion (#7622)

This commit is contained in:
Martin Dobroucký 2020-11-01 14:53:12 +01:00 коммит произвёл GitHub
Родитель c2ebd71732
Коммит cdaf3e9097
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 28 добавлений и 1 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -0,0 +1,5 @@
<Project>
<ItemGroup>
<PackageVersion Include="Autofac" Version="4.5.0" />
</ItemGroup>
</Project>

Просмотреть файл

@ -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 [

Просмотреть файл

@ -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(

Просмотреть файл

@ -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'),
];