C# 以编程方式更新NuGet包
我见过很多关于安装C# 以编程方式更新NuGet包,c#,uwp,nuget,C#,Uwp,Nuget,我见过很多关于安装NuGet软件包的问题和例子,但没有一个是关于更新软件包的 更新NuGet软件包的最佳方式是什么?我正试图从一个ASP.netmvc应用程序中执行此操作,以更新UWP项目中的包,该项目具有projec.json包引用 我是否也需要更新.csproj和project.json文件?在与NuGet.VisualStudio和NuGet.Core软件包进行斗争并花费大量时间后,我发现最好的方法是使用NuGet CLI和.NETProcess对象。下载nuget.exe后,以下是如何更
NuGet
软件包的问题和例子,但没有一个是关于更新软件包的
更新NuGet
软件包的最佳方式是什么?我正试图从一个ASP.netmvc
应用程序中执行此操作,以更新UWP
项目中的包,该项目具有projec.json
包引用
我是否也需要更新
.csproj
和project.json
文件?在与NuGet.VisualStudio
和NuGet.Core
软件包进行斗争并花费大量时间后,我发现最好的方法是使用NuGet CLI和.NETProcess
对象。下载nuget.exe
后,以下是如何更新软件包:
var updateOutput = new List<string>();
var updateError = new List<string>();
var updateProcess = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "the path to nuget.exe file",
Arguments = "update " + "project path including .csproj file",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
}
};
updateProcess.Start();
while (!updateProcess.StandardOutput.EndOfStream)
{
updateOutput.Add(updateProcess.StandardOutput.ReadLine());
}
while (!updateProcess.StandardError.EndOfStream)
{
updateError.Add(updateProcess.StandardError.ReadLine());
}
在与
NuGet.VisualStudio
和NuGet.Core
软件包斗争并花费了大量时间之后,我发现最好的方法是使用NuGet CLI和.NETProcess
对象。下载nuget.exe
后,以下是如何更新软件包:
var updateOutput = new List<string>();
var updateError = new List<string>();
var updateProcess = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "the path to nuget.exe file",
Arguments = "update " + "project path including .csproj file",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
}
};
updateProcess.Start();
while (!updateProcess.StandardOutput.EndOfStream)
{
updateOutput.Add(updateProcess.StandardOutput.ReadLine());
}
while (!updateProcess.StandardError.EndOfStream)
{
updateError.Add(updateProcess.StandardError.ReadLine());
}
有一些关于更新、恢复包等的数据。。请检查这是否对您有帮助。或者您可以使用工具来完成此操作,如“谢谢”,但没有一个有用。请注意,我正在尝试以编程方式(从C#代码)实现这一点。难道您不能在代码中通过命令行运行nuget cli吗?e、 g.我可以使用这个过程,但在它启动后,并没有结果,这意味着我不知道是否出了什么问题或它是否成功,等等,有一些关于更新、恢复包等的数据。。请检查这是否对您有帮助。或者您可以使用工具来完成此操作,如“谢谢”,但没有一个有用。请注意,我正在尝试以编程方式(从C#代码)实现这一点。难道您不能在代码中通过命令行运行nuget cli吗?e、 我可以使用这个过程,但在它开始之后,并没有结果,这意味着我不知道是否出了什么问题,或者它是否成功,等等