我有一个FAKE构建脚本,如果我使用VisualStudio构建项目,它将运行得非常好,但是如果我尝试进行新构建,那么它会抛出错误,说它无法找到两个数字的命名空间nuget包和我依赖的视觉工作室项目。
我正在使用FAKE的MSBuildRelease并传递.sln
文件,如下所示:
Target "BuildWindowsProject" (fun _ ->
MSBuildRelease
""
"Build"
[ "./Source/My.Project.sln" ]
|> Log "Windows-Build: "
)
它提供了一些错误,如下所示,但这些错误包括解决方案中的项目和外部nuget包。
The type or namespace name 'Caliburn' could not be found (are you missing a using directive or an assembly reference?)
我确实注意到早在2011年就发布了这个帖子 - MSBuild cannot find a reference但它已经很老了,我无法在网上找到最近发生的问题。
如果我首先进行visual studio构建然后运行我的构建脚本,但它没有解决构建服务器的问题。我做错了什么?
答案 0 :(得分:1)
你必须自己进行深度诊断,因为considiration下的问题需要在这里发布源代码,也可能取决于脚本运行的环境,以便得到正确的答案。
您可以选择MSBuild utility to pass verbosity level输出。使用以下开关值可获取有关在构建期间如何解析引用的详细信息:
msbuild ./Source/My.Project.sln /t:Build /v:d
使用此命令,您可以导航到名为 ResolveAssemblyReference 和 ResolveProjectReference 的步骤。您可以看到所有路径,它将搜索程序集,以及它是否成功:
4> Primary reference "System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
4> Resolved file path is "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Runtime.Remoting.dll".
4> Reference found at search path location "{TargetFrameworkDirectory}".
4> For SearchPath "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\amd64".
4> Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\amd64\System.Runtime.Remoting.winmd", but it didn't exist.
4> Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\amd64\System.Runtime.Remoting.dll", but it didn't exist.
4> Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\amd64\System.Runtime.Remoting.exe", but it didn't exist.
4> For SearchPath "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64".
4> Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64\System.Runtime.Remoting.winmd", but it didn't exist.
4> Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64\System.Runtime.Remoting.dll", but it didn't exist.
4> Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64\System.Runtime.Remoting.exe", but it didn't exist.
4> For SearchPath "{TargetFrameworkDirectory}".
4> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Runtime.Remoting.winmd", but it didn't exist.
4> This reference is not "CopyLocal" because it's a prerequisite file.
4> The ImageRuntimeVersion for this reference is "v4.0.30319".
如果查看由MSBuild生成的命令行并查明是否需要引用,您还可以检查传递给编译器的引用。
对于cl:
4> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\CL.exe
...
/AI"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"
...
/FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll"
/FUE:\YourProj\bin\Debug\Your.Proj.dll
/FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Configuration.dll"
...
/errorReport:prompt
YourSourceCodeFiles.cpp
/clr:nostdlib
对于csc:
2> C:\Program Files (x86)\MSBuild\12.0\bin\Csc.exe
...
/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\mscorlib.dll"
/reference:E:\svn\PRM\trunk\PRM30\bin\Debug\Prm.Base.dll
/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Configuration.dll"
/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Core.dll"
...
(为简单起见省略了大多数参数)