/// <nodoc /> public NugetProgress(INugetPackage package, Stopwatch stopwatch) { Contract.Requires(package != null); Contract.Requires(stopwatch != null); Package = package; m_stopwatch = stopwatch; }
/// <nodoc /> public NugetFailedWithNonZeroExitCodeFailure(INugetPackage package, int exitCode, string stdOut, string stdErr) : base(FailureType.PackageNotFound) { m_package = package; m_exitCode = exitCode; m_stdOut = stdOut?.Trim(); m_stdErr = stdErr?.Trim(); }
private bool ValidatePackageConfiguration(INugetPackage packageConfiguration) { if (!PathAtom.TryCreate(m_context.StringTable, packageConfiguration.Version, out _)) { Logger.Log.ConfigNugetPackageVersionIsInvalid(m_context.LoggingContext, packageConfiguration.Version, packageConfiguration.Id); return(false); } return(true); }
/// <nodoc /> public NugetPackage(INugetPackage template) { Id = template.Id; Version = template.Version; Alias = template.Alias; Tfm = template.Tfm; OsSkip = template.OsSkip ?? new List <string>(); DependentPackageIdsToSkip = template.DependentPackageIdsToSkip ?? new List <string>(); DependentPackageIdsToIgnore = template.DependentPackageIdsToIgnore ?? new List <string>(); ForceFullFrameworkQualifiersOnly = template.ForceFullFrameworkQualifiersOnly; }
private static IPropertyAccessExpression CreateImportFromForDependency(INugetPackage dependency) { // TODO: This is a terrible hack but we have same-named incompatible modules from the cache, this was the only workaround to get it working string importName = string.IsNullOrEmpty(dependency.Alias) || (dependency.Id == "BuildXL.Cache.ContentStore.Interfaces") ? dependency.Id : dependency.Alias; // importFrom('moduleName').pkg return(PropertyAccess( // TODO: Support multiple SxS versions, so this dependency would be the direct dependency. ImportFrom(importName), "pkg")); }
/// <summary> /// Nuget.exe failed to restore a package. /// </summary> public static NugetFailure CreateNugetInvocationFailure(INugetPackage package, int exitCode, string stdOut, string stdErr) { Contract.Requires(package != null); Contract.Requires(exitCode != 0); // If the stdOut has the following text: 'NotFound http' or 'WARNING: Unable to find version', it means that the package name or version are not found. if (stdOut.Contains("NotFound http") || stdOut.Contains("WARNING: Unable to find version")) { return(new CanNotFindPackageFailure(package)); } return(new NugetFailedWithNonZeroExitCodeFailure(package, exitCode, stdOut, stdErr)); }
/// <nodoc /> public NugetPackage(INugetPackage template) { Id = template.Id; Version = template.Version; Alias = template.Alias; Tfm = template.Tfm; DependentPackageIdsToSkip = template.DependentPackageIdsToSkip ?? new List <string>() { }; DependentPackageIdsToIgnore = template.DependentPackageIdsToIgnore ?? new List <string>() { }; }
/// <nodoc /> public PackageOnDisk(PathTable pathTable, INugetPackage package, PackageDownloadResult packageDownloadResult) { Contract.Requires(pathTable != null); Contract.Requires(package != null); Contract.Requires(packageDownloadResult != null); Package = package; PackageDownloadResult = packageDownloadResult; var nuspecFileName = PathAtom.Create(pathTable.StringTable, package.Id + ".nuspec"); GetSpecialFiles(pathTable, nuspecFileName, packageDownloadResult, out var nuSpecFile, out var moduleConfigFile); NuSpecFile = nuSpecFile; ModuleConfigFile = moduleConfigFile; }
private bool TryResolveNugetPackageVersion( Dictionary <string, INugetPackage> packagesOnConfig, INugetPackage requestorPackage, string id, string version, bool doNotEnforceDependencyVersions, out INugetPackage nugetPackage, out string errorMessage) { Contract.Assert(id != null); // First, the requestedId must exist in the list specified in the config file if (!packagesOnConfig.ContainsKey(id)) { nugetPackage = null; if (requestorPackage.DependentPackageIdsToIgnore.Contains(id) || requestorPackage.DependentPackageIdsToIgnore.Contains("*")) { errorMessage = null; return(true); } errorMessage = string.Format( CultureInfo.InvariantCulture, "The requested dependency with id '{0}' and version '{1}' is not explicitly listed in the configuration file.", id, version); return(false); } // Now we deal with the version. The candidate package is what we found above, but we have to validate the version is valid wrt the request var candidatePackage = packagesOnConfig[id]; // If the version is not specified, we use the one listed in the config if (version == null) { nugetPackage = candidatePackage; errorMessage = null; // This is just informative. We succeeded already. Logger.Log.NugetDependencyVersionWasNotSpecifiedButConfigOneWasChosen( m_context.LoggingContext, nugetPackage.Id, nugetPackage.Version); return(true); } // Now we parse the requested version to validate it is compatible with the one specified in the config if (!NuGetVersion.TryParse(candidatePackage.Version, out var packageOnConfigVersion)) { nugetPackage = null; errorMessage = string.Format( CultureInfo.InvariantCulture, "Version '{1}' on package '{0}' is malformed.", candidatePackage.Id, packagesOnConfig[id].Version); return(false); } if (VersionRange.TryParse(version, out var versionRange)) { if (versionRange.Satisfies(packageOnConfigVersion)) { nugetPackage = candidatePackage; errorMessage = null; // This is just informative. We succeeded already. Logger.Log.NugetDependencyVersionWasPickedWithinRange( m_context.LoggingContext, nugetPackage.Id, nugetPackage.Version, version); return(true); } if (doNotEnforceDependencyVersions) { nugetPackage = candidatePackage; errorMessage = null; // This is a warning, but we suceeded since versions are configured to not be enforced Logger.Log.NugetDependencyVersionDoesNotMatch( m_context.LoggingContext, requestorPackage.Id, requestorPackage.Version, nugetPackage.Id, nugetPackage.Version, version); return(true); } nugetPackage = null; errorMessage = string.Format( CultureInfo.InvariantCulture, "Package '{0}' is specified with version '{1}', but that is not contained in the interval '{2}'.", id, candidatePackage.Version, version); return(false); } nugetPackage = null; errorMessage = string.Format(CultureInfo.InvariantCulture, "Could not parse version '{0}'.", version); return(false); }
/// <nodoc /> public CanNotFindPackageFailure(INugetPackage package) : base(FailureType.PackageNotFound) { m_package = package; }
/// <nodoc /> public NugetFailure(INugetPackage package, FailureType failureType, Exception e = null) : this(failureType, e) { Package = package; }
public static string GetPackageIdentity(this INugetPackage nugetPackage) { Contract.Requires(!string.IsNullOrEmpty(nugetPackage.Id), "Every package should have an ID"); return(!string.IsNullOrEmpty(nugetPackage.Alias) ? nugetPackage.Alias : nugetPackage.Id); }