0

我使用 Squirrel.Windows 作为我的应用程序的更新框架,并且我从 1.4.4 升级到最新版本 1.5.2,在通过 NuGet 升级后,由于其保护级别,UpdateManager 类变得无法访问。

我创建了一个示例项目并通过 NuGet 导入了 Squirrel.Windows nuget 包,我能够毫无问题地实例化 UpdateManager 类的实例。我尝试清理所有与 Squirrel.Windows 项目相关的 NuGet 包,并清理了与它相关的 csproj 中剩余的任何信息,再次导入包后我仍然无法访问该类。

namespace Our.Core 
{
    public class Launcher
    {        
        public static void Main(string[] args)
        {
            new Launcher(args);
        }

        public async Task<bool> TryUpdate(string[] args)
        {
            try
            {
                using (var mgr = new UpdateManager(UpdatePath, null, null, null))
                {
                    Log.Information("Checking for updates");
                    var updateInfo = await mgr.CheckForUpdate();
                    if (updateInfo.ReleasesToApply.Any())
                    {
                        Log.Information("Downloading updates");
                        await mgr.DownloadReleases(updateInfo.ReleasesToApply);
                        Log.Information("Applying updates");
                        await mgr.ApplyReleases(updateInfo);

                        return true;
                    }
                    Log.Information("No updates found.");

                    return false;
                }
            }
            catch (Exception e)
            {
                Log.Error(e, "Error while updating");
                return false;
            }
        }
    }
}
4

1 回答 1

0

问题原来是在升级库后,项目中的引用将其特定版本属性切换为 false。这导致 Visual Studio 无法正确引用库的正确版本。

故事的道德,请确保检查您的版本,如果您需要使用特定版本,您的特定版本检查是正确的!

于 2017-03-09T16:12:50.920 回答