[英]MSBuild error finding the nuget.targets file
I'm trying to build a csproj project with msbuild, but having all sorts of weird issues with it complaining about not finding nuget.targets. 我正在尝试用msbuild构建一个csproj项目,但是它有各种奇怪的问题抱怨没有找到nuget.targets。
I run the simplest of command line builds with MSbuild: 我使用MSbuild运行最简单的命令行构建:
Msbuild Project.csproj
And that works in my normal dev folder, but in another folder location, it fails with these errors: 这可以在我的普通dev文件夹中工作,但在另一个文件夹位置,它会因以下错误而失败:
error MSB4019: The imported project "C:\\BuildAgent\\work\\CableSense\\.nuget\\nuget.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
That path ( C:\\BuildAgent\\work\\CableSense\\.nuget\\nuget.targets
) is actually wrong and is missing a folder after work (work\\somefolder\\cablesense), but I'm at a loss why. 该路径(
C:\\BuildAgent\\work\\CableSense\\.nuget\\nuget.targets
)实际上是错误的,并且在工作后缺少一个文件夹(work \\ somefolder \\ cablesense),但我不知道为什么。 More weirdly, if I build another project that is part of the solution, then that works, it's just this project. 更奇怪的是,如果我构建另一个项目,这是解决方案的一部分,那么这是有效的,它只是这个项目。
The csproj specifies the location of the nuget.targets file like this: csproj指定nuget.targets文件的位置,如下所示:
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
And the SolutionDir is defined like so: SolutionDir的定义如下:
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
Which is the same as the other project that does work. 这与其他有效的项目相同。 Any ideas?
有任何想法吗?
Argh! 哎呀! After posting this I found the issue.. Basically, the project had dependencies on other projects.
发布后我发现了问题..基本上,该项目依赖于其他项目。 The csproj files for those related projects were slightly wrong - and had this as the SolutionDir:
这些相关项目的csproj文件略有错误 - 并将其作为SolutionDir:
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\CableSense\</SolutionDir>
Which then caused the issue! 然后引起了这个问题! Hope this helps someone else there, I feel bad for answering my own question now.
希望这有助于那里的其他人,我现在对回答我自己的问题感到很难过。
OK, so I got the same error now recently but the solution worked out to be different for me. 好的,所以我最近得到了同样的错误,但解决方案对我来说有所不同。
In the Build Definition, under Source Settings, I had the Source Control Folder set to the directory of the actual project instead of the root folder for the solution. 在“构建定义”中的“源设置”下,我将源控制文件夹设置为实际项目的目录,而不是解决方案的根文件夹。
I know this is an old answered thread, but this might help someone who made the same mistake I did. 我知道这是一个老回答的帖子,但这可能会帮助那些犯了同样错误的人。
对我来说,我只是改变了解决方案的位置,以便有一个短的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.