Summary
When using NuGet Central Package Management with a pinned version number for the Antlr4.Runtime.Standard package, for example "[4.13.1]", the Antlr4BuildTools package is unable to download the Antlr4 tool jar file as expected. Consequently, the grammar file is not 'compiled' during the build and the build fails.
Introduction
When using NuGet Central Package Management, the Directory.Packages.props file contains the names and version numbers of each package.
This allows a centralised list of all the packages and their versions, and is useful for larger projects. The package version number can be set to a particular version, a minimum version, or a range of versions.
For example:
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageVersionOverrideEnabled>false</CentralPackageVersionOverrideEnabled>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Antlr4BuildTasks" Version="[12.11.0]" />
<!-- Don't use square brackets to pin version as this breaks Antlr4BuildTasks which attempts to read the Antlr4 version number,
in turn this causes the build to fail as the classes auto-generated from the grammar file are not generated.
Version="4.13.1" works
Version="[4.13.1]" fails
-->
<!--<PackageVersion Include="Antlr4.Runtime.Standard" Version="4.13.1" />-->
<PackageVersion Include="Antlr4.Runtime.Standard" Version="[4.13.1]" />
</ItemGroup>
</Project>
The Antlr4BuildTools package looks for the version number of the Antlr4.Runtime.Standard package (so that it can download and run the appropriate tools for that version of Antlr4).
Failure case
When the Antlr4.Runtime.Standard package version is pinned to a specific version with square brackets,
for example "[4.13.1]", Antlr4BuildTools is unable to download the Antlr4 tool jar file during the build.
The v2 match and v3 match are both empty.
Success cases
- Don't use square brackets to pin the version number, for example "12.11.0"
- Don't use Central Package Management, and instead specify the package version in the project file.
The v3 match indicates the expected 4.13.1 version number.
Repo case
See the attached example project.
DemoApp.zip
Further reading:
https://learn.microsoft.com/en-us/nuget/concepts/package-versioning
https://stackoverflow.com/questions/79383712/central-package-management-version-pinning
Summary
When using NuGet Central Package Management with a pinned version number for the
Antlr4.Runtime.Standardpackage, for example "[4.13.1]", theAntlr4BuildToolspackage is unable to download the Antlr4 tool jar file as expected. Consequently, the grammar file is not 'compiled' during the build and the build fails.Introduction
When using NuGet Central Package Management, the
Directory.Packages.propsfile contains the names and version numbers of each package.This allows a centralised list of all the packages and their versions, and is useful for larger projects. The package version number can be set to a particular version, a minimum version, or a range of versions.
For example:
The Antlr4BuildTools package looks for the version number of the
Antlr4.Runtime.Standardpackage (so that it can download and run the appropriate tools for that version ofAntlr4).Failure case
When the Antlr4.Runtime.Standard package version is pinned to a specific version with square brackets,
for example
"[4.13.1]",Antlr4BuildToolsis unable to download the Antlr4 tool jar file during the build.The v2 match and v3 match are both empty.
Success cases
The v3 match indicates the expected 4.13.1 version number.
Repo case
See the attached example project.
DemoApp.zip
Further reading:
https://learn.microsoft.com/en-us/nuget/concepts/package-versioning
https://stackoverflow.com/questions/79383712/central-package-management-version-pinning