2

我们有几个 .Net 4.0 解决方案,它们都依赖于由一个特定解决方案构建的程序集,即我们的 Server.sln(我猜 Shared.sln 会是一个更好的名称)。我们的构建过程首先使用MsBuild OutDir 参数将 Server.sln 构建到 Binaries 目录,然后将后续解决方案构建到子目录(例如 Binaries\Client、Binaries\Web 等),再次使用 OutDir 参数指定到适当的子目录。这使我们可以轻松地将单独的应用程序发布到不同的地方。这适用于我们所有的解决方案,除了我们创建的新 API.sln。

与其他解决方案一样,API.sln 引用了一些由 Server.sln 构建的 DLL,但我得到的实际编译错误是一个项目(我们称之为 Project1)找不到对 Project2 的引用。Project1和Project2都是API.sln中的项目,Project1通过项目引用引用Project2;不是 dll 文件参考。此外,Project2 也没有任何外部依赖项;它唯一的引用是SystemSystem.CoreSystem.Runtime.Serialization

如果我将 OutDir 设置为 Binaries 目录,一切正常,但我不想这样做,因为所有 API.sln 程序集都与所有 Server.sln 程序集混合在一起,这使得只部署 API。 sln 组件更难。当我将 OutDir 设置为 Binaries\API 时,我收到构建错误消息:

The name '[Project2 Class Name]' does not exist in the current context [Path to Project1.csproj]

我检查了一下,Project1.dll 和 Project2.dll 程序集都被创建到 Binaries\API 目录中,所以我不确定为什么会生成这个错误。我们的 TFS 构建服务器有这个问题,但我也可以通过使用相同参数在 .slns 上调用 MsBuild 在本地计算机上重新创建它。有任何想法吗?

以下是我用于实际构建的两个 msbuild 命令:

构建 Server.sln:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe /nologo "C:\PlatformAPIBuild\BuildProcessTests\Sources\RQ4.Server.sln" /nr:False /fl /flp:"logfile=C:\PlatformAPIBuild\BuildProcessTests\Sources\RQ4.Server.log;encoding=Unicode;verbosity=normal" /p:SkipInvalidConfigurations=true /p:ReferencePath=C:\PlatformAPIBuild\BuildProcessTests\Binaries  /p:OutDir="C:\PlatformAPIBuild\BuildProcessTests\Binaries\\" /p:Configuration="Release" /p:Platform="Any CPU" /p:VCBuildOverride="C:\PlatformAPIBuild\BuildProcessTests\Sources\RQ4.Server.sln.Any CPU.Release.vsprops"

然后构建 API.sln:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo "C:\PlatformAPIBuild\BuildProcessTests\Sources\IQ.Platform.PublicAPI.sln" /nr:False /fl /flp:"logfile=C:\PlatformAPIBuild\BuildProcessTests\Sources\IQ.Platform.PublicAPI.log;encoding=Unicode;verbosity=normal" /p:SkipInvalidConfigurations=true /p:ReferencePath=C:\PlatformAPIBuild\BuildProcessTests\Binaries  /p:OutDir="C:\PlatformAPIBuild\BuildProcessTests\Binaries\Platform.PublicAPI\\" /p:Configuration="Release" /p:Platform="Any CPU" /p:VCBuildOverride="C:\PlatformAPIBuild\BuildProcessTests\Sources\IQ.Platform.PublicAPI.sln.Any CPU.Release.vsprops" 

这是来自 API.sln 构建的日志文件。您会注意到它有错误,例如,

Warning as Error: Reference to type 'IQ.Platform.Framework.WebApi.Model.Hypermedia.AccessControl' claims it is defined in 'c:\PlatformAPIBuild\BuildProcessTests\Binaries\Platform.PublicAPI\IQ.Platform.Framework.WebApi.Model.dll', but it could not be found

但是它说的文件不存在,当我在构建失败后查找它时实际上存在,并且您可以看到它在日志文件顶部所做的第一件事就是将该程序集复制到该路径,所以我不确定为什么它找不到它。IQ.Platform.Framework.WebApi.Model 是我上面讨论的 Project2。

这是来自 API.sln 构建的日志文件,其中删除了所有测试项目,因此只剩下一个错误,希望这将使查看日志文件更容易一些。这是相同的日志,但具有诊断冗长性

4

0 回答 0