FAKE MSBuild 步骤无法解析引用
FAKE MSBuild step can't resolve references
我有一个 FAKE 构建脚本,如果我使用 VisualStudio 构建一次项目,它将 运行 完美无缺,但如果我尝试重新构建,它会抛出错误,提示找不到命名空间许多 nuget 包和我依赖的 visual studio 个项目。
我正在使用 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 构建然后 运行 我的构建脚本就可以正常工作,但这并不能解决构建服务器的问题。我做错了什么?
你必须自己进行深度诊断,因为正在考虑的问题需要在这里发布源代码。它还可以取决于脚本所在的环境 运行,以便为您提供正确的答案。
您可以选择 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.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"
...
(为简单起见省略了大部分参数)
我有一个 FAKE 构建脚本,如果我使用 VisualStudio 构建一次项目,它将 运行 完美无缺,但如果我尝试重新构建,它会抛出错误,提示找不到命名空间许多 nuget 包和我依赖的 visual studio 个项目。
我正在使用 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 构建然后 运行 我的构建脚本就可以正常工作,但这并不能解决构建服务器的问题。我做错了什么?
你必须自己进行深度诊断,因为正在考虑的问题需要在这里发布源代码。它还可以取决于脚本所在的环境 运行,以便为您提供正确的答案。
您可以选择 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.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"
...
(为简单起见省略了大部分参数)