[英]nuget command Source Add started to fail out of nowhere with a warning asking for a unique source
I have an c# wpf application and an additional installer project to create an installer of the application.我有一个 c# wpf 应用程序和一个额外的安装程序项目来创建应用程序的安装程序。 Among many other files, the installer project has a installer.cmd file (I took over it from someone else) and a Product.wxs file.
在许多其他文件中,安装程序项目有一个 installer.cmd 文件(我从别人那里接手的)和一个 Product.wxs 文件。 I was able to create an installer by running
msbuild tools\installer.cmd /P:Library.net461 /P:Platform=x64
command on the developper comand prompt.我能够通过在 developper 命令提示符下运行
msbuild tools\installer.cmd /P:Library.net461 /P:Platform=x64
命令来创建安装程序。
I was trying to create a desktop shortcut in all user's desktops and was playing with *.wxs file for that.我试图在所有用户的桌面上创建一个桌面快捷方式,并为此使用 *.wxs 文件。 I know you guys will roast me because of the following sentence but I don't know what else can I say.
我知道你们会因为下面这句话而烤我,但我不知道我还能说什么。 Something I did break something and somehow the
msbuild
starts to give error.我确实破坏了一些东西,不知何故
msbuild
开始出错。 I cannot say what I did because I tried many different things.. I went back to original project but it didn't help.我不能说我做了什么,因为我尝试了很多不同的东西。我回到了原来的项目,但没有帮助。 So what is done is done.
所以已经完成了。 I will talk about the error now.
我现在将讨论错误。
The error itself doesn't tell much:错误本身并不能说明什么:
C:\workspace\QToolInstaller\tools\installer.cmd(117,5): error MSB3073: The command "nuget Source Add -Name PkgSrc_638107674121812897 -Source C:\workspace\QToolInstaller\exports" exited with code 1.
I checked online to understand this error code but there wasn't much.我在线检查以了解此错误代码,但并不多。 However there is another line just before this erorr line:
但是,在此错误行之前还有另一行:
The source specified has already been added to the list of available package sources. Provide a unique source.
Well, this wasn't in usual warning color or marked as a warning.好吧,这不是通常的警告颜色或标记为警告。 But I think it is worth to investigate.
但我认为值得研究。
So the "source" mentioned here is PkgSrc_638107674121812897
.所以这里说的“来源”是
PkgSrc_638107674121812897
。 I scanned the installer.cmd to see where is this coming form and saw that this file is named by using time ticks as:我扫描了 installer.cmd 以查看即将到来的表格在哪里,并看到该文件使用时间标记命名为:
<LocalSource>PkgSrc_$([System.DateTime]::UtcNow.Ticks)</LocalSource>
Although I ran the msbuild
command multiple times, the name of the source is always different.虽然我多次运行
msbuild
命令,但源的名称总是不同的。 I ran the command in diagnostic mode by using -verbosity:diag
option.我使用
-verbosity:diag
选项在诊断模式下运行命令。 And I checked the file name among all the logs.我检查了所有日志中的文件名。 There is no match.
没有匹配项。 I tried to change the name to something ridicolous that cannot be listed anywhere but got the same error.
我试图将名称更改为无法在任何地方列出但出现相同错误的可笑名称。 Removed alll the files, created them again, restarted the PC etc. Nothing have changed.
删除所有文件,重新创建它们,重新启动 PC 等。没有任何改变。 This name is really unique and but still I am getting this message.
这个名字真的很独特,但我仍然收到这条消息。 I wish I had logs form previous successfull runs.
我希望我有以前成功运行的日志。 I cannot tell if this is the cause of the failure or not.
我不知道这是否是失败的原因。 Does any of these ring any bell fellas?
这些中的任何一个都会响铃吗?
It is solved.它被解决了。 Luckily a colleague of mine have faced with this before.
幸运的是,我的一位同事以前遇到过这种情况。 I hope no one will have to deal with this problem again.
我希望没有人会再次处理这个问题。
So apparently there is a bug(?).所以显然有一个错误(?)。 Altought that name is unique it thinks the opposite.
Altought 这个名字是独一无二的,它认为相反。 When I do list the sources with thw followng command
当我使用 thw followng 命令列出来源时
nuget source
among the one that should be there, there is one extra line as PkgSrc_638107643440982987
.在应该存在的那一行中,有一行是
PkgSrc_638107643440982987
。 Although my installer.cmd
suppose to remove the source every time after it is done, it didn't for once.尽管我的
installer.cmd
假设每次完成后都删除源,但一次都没有。 And although the new source is named differently, it doesn't care and gives that non-warning, non-error message followed by a meaningless error code 1 message.尽管新源的名称不同,但它并不关心并给出非警告、非错误消息,后跟无意义的错误代码 1 消息。 How to solve it?
如何解决?
We tried to remove the source by command prompt like this:我们尝试通过命令提示符删除源代码,如下所示:
nuget source delete -Name PkgSrc_638107643440982987
But it is not deleted.但它并没有被删除。 So we went to the Visual Studio->Tools->NuGet Package Manager->Package Manager Settings->Package Sources.
所以我们去了 Visual Studio->Tools->NuGet Package Manager->Package Manager Settings->Package Sources。 Found the guilty source and remove it.
找到有罪的来源并将其删除。 And then it is resolved.
然后就解决了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.