Skip to content

Commit

Permalink
fix(core): resolved package version not provided (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
dasco144 authored Apr 13, 2022
1 parent e2db293 commit 9bbc7c1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions packages/core/src/generators/nuget-reference/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,25 @@ describe('nuget-reference generator', () => {
await generator(appTree, options, dotnetClient);
expect(prompt).toHaveBeenCalledTimes(1);
});

it('provides resolved version to dotnet add package reference', async () => {
const { getProjectFileForNxProject } = await import('@nx-dotnet/utils');

const projectFilePath = 'libs/test/Test.csproj';

(getProjectFileForNxProject as jest.MockedFunction<() => Promise<string>>)
.mockReset()
.mockResolvedValue(projectFilePath);

updateConfig(appTree, {
nugetPackages: { [options.packageName]: '1.2.3' },
});
await generator(appTree, options, dotnetClient);
const mock = dotnetClient as jest.Mocked<DotNetClient>;
expect(mock.addPackageReference).toHaveBeenCalledWith(
projectFilePath,
options.packageName,
{ allowVersionMismatch: false, version: '1.2.3' },
);
});
});
2 changes: 1 addition & 1 deletion packages/core/src/generators/nuget-reference/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default async function (
resolvedVersion !== options.version &&
resolvedVersion !== ALLOW_MISMATCH
) {
options.version = resolvedVersion;
params.version = resolvedVersion;
}

try {
Expand Down

0 comments on commit 9bbc7c1

Please sign in to comment.