gpt4 book ai didi

c# - 如何在不在 csproj 中链接到项目的情况下引用项目?

转载 作者:行者123 更新时间:2023-11-30 15:29:55 25 4
gpt4 key购买 nike

我有一个测试项目,它运行一个程序 (a .exe) 并确保结果按预期出现。

我想声明测试项目依赖于构建 .exe 的项目, 并放置 .exe放入 $(OutDir) 的子目录中(或 $(OutputPath) )。

  • $(OutDir)MyTests.dll (测试项目)
  • $(OutDir)\Product\Foo.exe (测试项目)
  • $(OutDir)\Product\xxx.dll (被测项目的依赖项)

这样我就可以编写表单的测试:

[TestClass]
[DeploymentItem("Product", "Product")]
public class RunFoo
{
[TestMethod]
public void HelpTextMatches()
{
// System.Diagnostics.Process.Start("Product\foo.exe" ...)
}
}

有没有办法声明类似 <ProjectReference 的东西?在我的测试中.csproj哪个文件可以让我实现这一目标?

(我不想让 <Copy 任务获取被测程序的输出,因为这样就没有什么可以强制 MSBuild 在测试项目之前构建被测程序。)

最佳答案

I'd like to declare that the test project depends on the project that builds the .exe...

在项目引用 ( source ) 上将 ReferenceOutputAssembly 设置为 false:

<ProjectReference Include="..\ProjectA\ProjectA.csproj">
<Project>{b402782f-de0a-41fa-b364-60612a786fb2}</Project>
<Name>ProjectA</Name>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>

...and place the .exe drop into a subdirectory of $(OutDir) (or $(OutputPath))

构建后操作。或者就地运行测试下的 exe。

关于c# - 如何在不在 csproj 中链接到项目的情况下引用项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23002441/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com