private static void ValidateXCopyPackageAndGetVersion(string packagePath, out string codeVersion) { foreach (string childFolder in ChildFoldersInXcopyPackage) { string newPath = Path.Combine(packagePath, childFolder); if (!FabricDirectory.Exists(newPath)) { ImageBuilderUtility.TraceAndThrowValidationError( FabricProvisionOperation.TraceType, StringResources.ImageStoreError_ChildFolderDoesNotExist_Formatted, childFolder, packagePath); } } codeVersion = "0.0.0.0"; var fabricExeCollection = FabricDirectory.GetFiles(packagePath, "fabric.exe", true, SearchOption.AllDirectories); if (fabricExeCollection.Count() == 0) { ImageBuilderUtility.TraceAndThrowValidationError( FabricProvisionOperation.TraceType, StringResources.ImageStoreError_FabricExeNotFound); } // Build number in version might have leading 0's i.e. 3.0.00123.0 // This causes issues during download, hence trimming the leading 0's #if DotNetCoreClrLinux var versionString = FileVersionInfo.GetVersionInfo(fabricExeCollection.First()).ProductVersion; #else var versionString = FabricFile.GetVersionInfo(fabricExeCollection.First()); #endif Version productVersion = null; if (!Version.TryParse(versionString, out productVersion)) { ImageBuilderUtility.TraceAndThrowValidationError( FabricProvisionOperation.TraceType, StringResources.ImageStoreError_InvalidProductVersion, versionString); } codeVersion = productVersion.ToString(); }