{"record":{"id":"4038ddf8657b359c","repo":"OrchardCMS/OrchardCore","slug":"the-resource-version-should-be-in-the-form-of-major-minor","errorCode":null,"errorMessage":"The resource version should be in the form of major.minor[.build[.revision]].","messagePattern":"The resource version should be in the form of major\\.minor\\[\\.build\\[\\.revision\\]\\]\\.","errorType":"validation","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.ResourceManagement.Abstractions/ResourceDefinition.cs","lineNumber":131,"sourceCode":"        {\n            UrlCdnDebug = cdnUrlDebug;\n        }\n        if (cdnSupportsSsl.HasValue)\n        {\n            CdnSupportsSsl = cdnSupportsSsl.Value;\n        }\n        return this;\n    }\n\n    /// <summary>\n    /// Sets the version of the resource.\n    /// </summary>\n    /// <param name=\"version\">The version to set, in the form of. <code>major.minor[.build[.revision]]</code></param>\n    public ResourceDefinition SetVersion(string version)\n    {\n        if (!System.Version.TryParse(version, out _))\n        {\n            throw new FormatException(\"The resource version should be in the form of major.minor[.build[.revision]].\");\n        }\n\n        Version = version;\n\n        return this;\n    }\n\n    /// <summary>\n    /// Should a file version be appended to the resource.\n    /// </summary>\n    /// <param name=\"appendVersion\"></param>\n    public ResourceDefinition ShouldAppendVersion(bool? appendVersion)\n    {\n        AppendVersion = appendVersion;\n        return this;\n    }\n\n    public ResourceDefinition SetCultures(params string[] cultures)","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.ResourceManagement.Abstractions/ResourceDefinition.cs#L113-L149","documentation":"ResourceDefinition.SetVersion validates the supplied version string with System.Version.TryParse and throws a FormatException when it does not parse. Resource versions must be numeric in the form major.minor[.build[.revision]].","triggerScenarios":"Calling SetVersion in a ResourceManifest with a string like '1.x', 'latest', '1.2.3-beta', a SemVer with prerelease suffix, or any non-numeric version token.","commonSituations":"Manifest authors copy a package.json SemVer (e.g. '3.5.13' fine, but '3.5.13-beta.1' not) or pass a variable/placeholder or URL fragment instead of a numeric version; CDN versions like 'v1.2' with a leading 'v'.","solutions":["Pass a numeric version parseable by System.Version, e.g. '1.2.3'.","Strip prerelease/build suffixes or the leading 'v' before calling SetVersion.","If the version is unknown, omit SetVersion entirely instead of passing a placeholder.","Wrap parsing yourself first: System.Version.TryParse(candidate, out _) in a guard before calling the API."],"exampleFix":"// before\nmanifest.DefineResource(\"script\", \"Foo\").SetVersion(\"1.2.3-beta.1\");\n// after\nmanifest.DefineResource(\"script\", \"Foo\").SetVersion(\"1.2.3\");","handlingStrategy":"validation","validationCode":"if (!System.Version.TryParse(candidateVersion, out _))\n    throw new FormatException($\"'{candidateVersion}' is not a valid resource version (major.minor[.build[.revision]]).\");","typeGuard":"static bool IsValidResourceVersion(string v) => System.Version.TryParse(v, out _);","tryCatchPattern":"try\n{\n    definition.SetVersion(version);\n}\ncatch (FormatException)\n{\n    logger.LogWarning(\"Invalid resource version '{Version}' ignored.\", version);\n}","preventionTips":["Store package versions as plain numeric strings; strip 'v' prefixes and SemVer suffixes.","Add a unit test that builds the manifest so SetVersion throws at build/test time, not runtime.","Never pass user- or config-supplied version strings directly without TryParse.","Omit SetVersion when the version is dynamic or unknown."],"tags":["resources","orchardcore","versioning","format"],"backgroundTag":"invalid-argument-format","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}