Skip to content

Commit

Permalink
Support msbuild central package versions
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed May 24, 2022
1 parent b878372 commit 7de194c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 10 additions & 3 deletions lib/modules/manager/nuget/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import type {
UpdateArtifactsConfig,
UpdateArtifactsResult,
} from '../types';
import { CENTRAL_FILE, getDependentPackageFiles } from './package-tree';
import {
MSBUILD_CENTRAL_FILE,
NUGET_CENTRAL_FILE,
getDependentPackageFiles,
} from './package-tree';
import {
getConfiguredRegistries,
getDefaultRegistries,
Expand Down Expand Up @@ -117,9 +121,12 @@ export async function updateArtifacts({
logger.debug(`nuget.updateArtifacts(${packageFileName})`);

// https://github.com/NuGet/Home/wiki/Centrally-managing-NuGet-package-versions
// https://github.com/microsoft/MSBuildSdks/tree/main/src/CentralPackageVersions
const isCentralManament =
packageFileName === CENTRAL_FILE ||
packageFileName.endsWith(`/${CENTRAL_FILE}`);
packageFileName === NUGET_CENTRAL_FILE ||
packageFileName === MSBUILD_CENTRAL_FILE ||
packageFileName.endsWith(`/${NUGET_CENTRAL_FILE}`) ||
packageFileName.endsWith(`/${MSBUILD_CENTRAL_FILE}`);

if (
!isCentralManament &&
Expand Down
9 changes: 7 additions & 2 deletions lib/modules/manager/nuget/package-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { logger } from '../../../logger';
import { readLocalFile } from '../../../util/fs';
import { getFileList } from '../../../util/git';

export const CENTRAL_FILE = 'Directory.Packages.props';
export const NUGET_CENTRAL_FILE = 'Directory.Packages.props';
export const MSBUILD_CENTRAL_FILE = 'Packages.props';

/**
* Get all package files at any level of ancestry that depend on packageFileName
*/
Expand All @@ -22,7 +24,10 @@ export async function getDependentPackageFiles(
}

const parentDir =
packageFileName === CENTRAL_FILE ? '' : upath.dirname(packageFileName);
packageFileName === NUGET_CENTRAL_FILE ||
packageFileName === MSBUILD_CENTRAL_FILE
? ''
: upath.dirname(packageFileName);

for (const f of packageFiles) {
graph.addNode(f);
Expand Down

0 comments on commit 7de194c

Please sign in to comment.