Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cake fails to resolve dependency of Semver 3.0.0 #90

Closed
rngcntr opened this issue Nov 26, 2024 · 2 comments
Closed

Cake fails to resolve dependency of Semver 3.0.0 #90

rngcntr opened this issue Nov 26, 2024 · 2 comments
Labels
answered A question that has been answered question

Comments

@rngcntr
Copy link

rngcntr commented Nov 26, 2024

Describe the bug
We are using Semver in our dotnet cake file to configure the build depending on the version of our project. Since updating to Semver 3.0.0, our builds fail with the following error:

Could not load /data/tools/Addins/Semver.3.0.0/lib/net5.0/Semver.dll (missing Microsoft.Extensions.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
Error: Could not load file or assembly 'Microsoft.Extensions.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

Steps To Reproduce
I built a minimal working/non-working exampe which consists of only two lines of build.cake:

#addin nuget:?package=semver&version=3.0.0
Semver.SemVersion.Parse("1.0.0", Semver.SemVersionStyles.Any);

Using the official SDK Docker image, the build fails.
See https://github.com/rngcntr/semver-demo for further instructions.

Expected behavior
The build should succeed using version 3.0.0, as it did before with version 2.3.0

Versions(please complete the following information):

  • Package Version: 3.0.0
  • Framework Version: NET8, NET9
@WalkerCodeRanger
Copy link
Owner

I believe this is because Cake doesn't load dependencies of add-ins by default. The Addin directive > Dependencies section of the docs says this and says that you can specify loaddependencies=true to cause it to load dependencies. So your build.cake file would be:

#addin nuget:?package=semver&version=3.0.0&loaddependencies=true
Semver.SemVersion.Parse("1.0.0", Semver.SemVersionStyles.Any);

I haven't tried this myself yet, but I assume it will work. Please let me know if that doesn't address the problem.

Why did this change with SemVer 3.0: The dependency on Microsoft.Extensions.Primitives primitives was added in v3.0.0. In v2.x.x versions there was no dependencies on any other NuGet packages. The dependency was added to replace and extend code that was previously part of the package for StringSegement. Using Microsoft.Extensions.Primitives improved performance because it uses Span[T].

@WalkerCodeRanger WalkerCodeRanger added question answered A question that has been answered and removed needs triaged labels Nov 27, 2024
@WalkerCodeRanger WalkerCodeRanger changed the title Cake fails to resolve Semver 3.0.0 Cake fails to resolve dependency of Semver 3.0.0 Nov 27, 2024
@rngcntr
Copy link
Author

rngcntr commented Nov 27, 2024

Thanks for your investigation. I can confirm that this solves the issue!

@rngcntr rngcntr closed this as completed Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered A question that has been answered question
Projects
None yet
Development

No branches or pull requests

2 participants