private async void Application_Startup(object sender, StartupEventArgs e)
        {
            MigrateSettings();

            var window = Container.GetExportedValue <MainWindow>();

            window.Show();

            //Disable this sellup as it doesn't work well with Windows 10 and the Windows Store application is not maintained.
            //CheckWindows8AndDisplayUpsellDialog();

            if (e.Args.Length > 0)
            {
                string file       = e.Args[0];
                bool   successful = await LoadFile(window, file);

                if (successful)
                {
                    return;
                }
            }

            // activation via ClickOnce url
            if (ApplicationDeployment.IsNetworkDeployed &&
                ApplicationDeployment.CurrentDeployment != null &&
                ApplicationDeployment.CurrentDeployment.ActivationUri != null)
            {
                string queryString = ApplicationDeployment.CurrentDeployment.ActivationUri.Query;
                var    arguments   = HttpUtility.ParseQueryString(queryString);

                string downloadUrl = arguments["url"];
                Uri    uri;

                if (!String.IsNullOrEmpty(downloadUrl) && Uri.TryCreate(downloadUrl, UriKind.Absolute, out uri))
                {
                    string id                     = arguments["id"];
                    string versionString          = arguments["version"];
                    NuGet.SemanticVersion version = null;
                    NuGet.SemanticVersion.TryParse(versionString, out version);

                    await window.DownloadAndOpenDataServicePackage(downloadUrl, id, version);

                    return;
                }
            }

            if (AppDomain.CurrentDomain.SetupInformation != null &&
                AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null)
            {
                // click-once deployment
                string[] activationData = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData;
                if (activationData != null && activationData.Length > 0)
                {
                    string file = activationData[0];
                    await LoadFile(window, file);

                    return;
                }
            }
        }
Beispiel #2
0
        private NuGetReference TryParseNuGetReference(string argumentValue)
        {
            // The argument value will be in one of the following forms:
            // [package id]
            // [package id]:[version]

            string packageId;
            NuGet.SemanticVersion packageVersion = null;

            int lastIndex = argumentValue.LastIndexOf(':');
            if (lastIndex > -1)
            {
                packageId = argumentValue.Substring(0, lastIndex);
                string rawVersion = argumentValue.Substring(lastIndex + 1);

                if (string.IsNullOrWhiteSpace(packageId))
                {
                    this.logger.LogError(CmdLineResources.ERROR_MissingPackageId, rawVersion);
                    return null;
                }

                if (!NuGet.SemanticVersion.TryParse(rawVersion, out packageVersion))
                {
                    this.logger.LogError(CmdLineResources.ERROR_InvalidVersion, rawVersion);
                    return null;
                }
            }
            else
            {
                packageId = argumentValue;
            }
            this.logger.LogDebug(CmdLineResources.DEBUG_ParsedReference, packageId, packageVersion);

            return new NuGetReference(packageId, packageVersion);
        }
Beispiel #3
0
 internal static PackageVersion FromSemanticVersion(NuGet.SemanticVersion semanticVersion)
 {
     if (semanticVersion == null)
     {
         return(null);
     }
     return(new PackageVersion(semanticVersion.ToString()));
 }
Beispiel #4
0
        public CoreInteropPackage(JObject json)
        {
            Id      = json.Value <string>("id");
            Version = NuGetVersion.Parse(json.Value <string>("version"));
            _oldVer = CoreConverters.SafeToSemanticVersion(Version);

            Json = json;
        }
Beispiel #5
0
        private async Task OpenPackageFromRepository(string searchTerm)
        {
            bool canceled = AskToSaveCurrentFile();

            if (canceled)
            {
                return;
            }

            PackageInfo selectedPackageInfo = PackageChooser.SelectPackage(searchTerm);

            if (selectedPackageInfo == null)
            {
                return;
            }

            if (selectedPackageInfo.IsLocalPackage)
            {
                await OpenLocalPackage(selectedPackageInfo.DownloadUrl.LocalPath);
            }
            else
            {
                var      packageVersion = new NuGet.SemanticVersion(selectedPackageInfo.Version);
                IPackage cachePackage   = MachineCache.Default.FindPackage(selectedPackageInfo.Id, packageVersion);

                Func <IPackage, DispatcherOperation> processPackageAction = (package) =>
                {
                    DataServicePackage servicePackage = selectedPackageInfo.AsDataServicePackage();
                    servicePackage.CorePackage = package;
                    LoadPackage(servicePackage,
                                selectedPackageInfo.DownloadUrl.ToString(),
                                PackageType.DataServicePackage);

                    // adding package to the cache, but with low priority
                    return(Dispatcher.BeginInvoke(
                               (Action <IPackage>)MachineCache.Default.AddPackage,
                               DispatcherPriority.ApplicationIdle,
                               package));
                };

                if (cachePackage == null || cachePackage.GetHash() != selectedPackageInfo.PackageHash)
                {
                    IPackage downloadedPackage = await PackageDownloader.Download(
                        selectedPackageInfo.DownloadUrl,
                        selectedPackageInfo.Id,
                        packageVersion.ToString());

                    if (downloadedPackage != null)
                    {
                        await processPackageAction(downloadedPackage);
                    }
                }
                else
                {
                    await processPackageAction(cachePackage);
                }
            }
        }
 public NuGetReference(string packageId, NuGet.SemanticVersion version)
 {
     if (string.IsNullOrWhiteSpace(packageId))
     {
         throw new ArgumentNullException("packageId");
     }
     this.packageId = packageId;
     this.version = version;
 }
Beispiel #7
0
 public NuGetReference(string packageId, NuGet.SemanticVersion version)
 {
     if (string.IsNullOrWhiteSpace(packageId))
     {
         throw new ArgumentNullException(nameof(packageId));
     }
     PackageId = packageId;
     Version   = version;
 }
Beispiel #8
0
        public static PackageVersion ToPackageVersion([NotNull] this NuGet.SemanticVersion version)
        {
            if (version == null)
            {
                throw new ArgumentNullException(nameof(version));
            }

            return(new PackageVersion(version.Version, version.SpecialVersion));
        }
Beispiel #9
0
 public NuGetReference(string packageId, NuGet.SemanticVersion version)
 {
     if (string.IsNullOrWhiteSpace(packageId))
     {
         throw new ArgumentNullException("packageId");
     }
     this.packageId = packageId;
     this.version   = version;
 }
        public IPackage FindPackage(string packageId, NuGet.SemanticVersion version)
        {
            string path = GetPackageFilePath(packageId, version);

            if (File.Exists(path))
            {
                return(new ZipPackage(path));
            }
            else
            {
                return(null);
            }
        }
Beispiel #11
0
        private void AddRuntimeServiceBreadcrumb()
        {
#if DNX451
            var runtimeAssembly = typeof(Servicing.Breadcrumbs).Assembly;
#else
            var runtimeAssembly = typeof(Servicing.Breadcrumbs).GetTypeInfo().Assembly;
#endif

            var version = runtimeAssembly
                          ?.GetCustomAttribute <AssemblyInformationalVersionAttribute>()
                          ?.InformationalVersion;

            if (!string.IsNullOrWhiteSpace(version))
            {
                var semanticVersion = new NuGet.SemanticVersion(version);
                Servicing.Breadcrumbs.Instance.AddBreadcrumb(runtimeAssembly.GetName().Name, semanticVersion);
            }
        }
Beispiel #12
0
        public IEnumerable <PackageResult> list_run(ChocolateyConfiguration config)
        {
            this.Log().Info(() => "");

            string match = config.Input;

            if (String.IsNullOrEmpty(match))
            {
                match = "*";
            }
            var reMatcher = FindFilesPatternToRegex.Convert(match);

            foreach (var key in get_apps())
            {
                if (!reMatcher.IsMatch(key.DisplayName))
                {
                    continue;
                }

                var r = new PackageResult(key.DisplayName, key.DisplayName, key.InstallLocation);
                NuGet.SemanticVersion version;

                if (!NuGet.SemanticVersion.TryParse(key.DisplayVersion, out version))
                {
                    version = new NuGet.SemanticVersion(1, 0, 0, 0);
                }

                var rp = new NuGet.RegistryPackage()
                {
                    Id = key.DisplayName, Version = version
                };
                r.Package      = rp;
                rp.IsPinned    = key.IsPinned;
                rp.RegistryKey = key;
                yield return(r);
            }
        }
 public ProjectPackage(ILogger logger, IOctopusServer server, ProjectResource project, ReleaseResource release, bool isLatest) : base(logger, server, project, SemanticVersion.Parse(release.Version))
 {
     Release         = release;
     IsLatestVersion = isLatest;
 }
 private string GetPackageFilePath(string id, NuGet.SemanticVersion version)
 {
     return(Path.Combine(Source, id + "." + version + Constants.PackageExtension));
 }
 private static bool IsPreReleasedVersion(NuGet.SemanticVersion version)
 {
     return(version != null && !String.IsNullOrEmpty(version.SpecialVersion));
 }
Beispiel #16
0
        internal async Task DownloadAndOpenDataServicePackage(string packageUrl, string id = null, NuGet.SemanticVersion version = null)
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                UIServices.Show(
                    StringResources.NoNetworkConnection,
                    MessageLevel.Warning);
                return;
            }

            Uri downloadUrl;

            if (Uri.TryCreate(packageUrl, UriKind.Absolute, out downloadUrl) && downloadUrl.IsRemoteUri())
            {
                IPackage downloadedPackage = await PackageDownloader.Download(downloadUrl, id, version.ToString());

                if (downloadedPackage != null)
                {
                    LoadPackage(downloadedPackage, packageUrl, PackageType.DataServicePackage);
                }
            }
            else
            {
                UIServices.Show(
                    String.Format(
                        CultureInfo.CurrentCulture,
                        StringResources.Dialog_InvalidPackageUrl,
                        packageUrl),
                    MessageLevel.Error
                    );
            }
        }
Beispiel #17
0
        private void AddRuntimeServiceBreadcrumb()
        {
            #if DNX451
            var runtimeAssembly = typeof(Servicing.Breadcrumbs).Assembly;
            #else
            var runtimeAssembly = typeof(Servicing.Breadcrumbs).GetTypeInfo().Assembly;
            #endif

            var version = runtimeAssembly
                ?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
                ?.InformationalVersion;

            if (!string.IsNullOrWhiteSpace(version))
            {
                var semanticVersion = new NuGet.SemanticVersion(version);
                Servicing.Breadcrumbs.Instance.AddBreadcrumb(runtimeAssembly.GetName().Name, semanticVersion);
            }
        }