我有这个解决方案的结构:
Solution.sln
|--WebUI.csproj (has Core.csproj as dependency)
|--Core.csproj
|--Tests
|--UnitTests
|--WebUI.UnitTest.csproj (has Core.csproj and WebUI.csproj as dependencies)
|--Core.UnitTest.csproj (has Core.csproj as dependency) 我应该在WebUI.csproj中添加什么来共同构建WebUI.UnitTest.csproj和Core.UnitTest.csproj?(在我的WebUI\bin文件夹中,我需要这些库: WebUI.UnitTest.dll和Core.UnitTest.dll)。
谢谢!
发布于 2017-02-14 08:35:17
直接的方法是添加WebUI.UnitTest项目和Core.UnitTest项目作为WebUI项目的依赖项。但是WebUI.UnitTest项目已经将WebUI.csproj作为依赖项,此方法在解决方案结构中不起作用。如果您只希望WebUI\bin文件夹中有WebUI.UnitTest.dll和Core.UnitTest.dll,可以在WebUI.csproj中添加一个任务将这些文件复制到文件夹中:
<Target Name="AfterBuild">
<PropertyGroup>
<SolutionDir>$([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))</SolutionDir>
</PropertyGroup>
<Exec Command=""$(MSBuildBinPath)\MSBuild.exe" "$(SolutionDir)\WebUI.UnitTest\WebUI.UnitTest.csproj"" />
<Exec Command=""$(MSBuildBinPath)\MSBuild.exe" "$(SolutionDir)\Core.UnitTest\Core.UnitTest.csproj"" />
<PropertyGroup>
<CopyFileOutput>$(SolutionDir)\WebUI.UnitTest\bin\Debug\WebUI.UnitTest.dll;$(SolutionDir)\Core.UnitTest\bin\Debug\Core.UnitTest.dll</CopyFileOutput>
</PropertyGroup>
<Copy
SourceFiles="$(CopyFileOutput)"
DestinationFolder="$(SolutionDir)\WebUI\bin"
/> 注意:的评论是对的,你构建了解决方案,WebUI.UnitTest.csproj和Core.UnitTest.csproj应该已经构建好了。
我还在WebUI.UnitTest.csproj和Core.UnitTest.csproj的WebUI.csproj中添加了构建步骤,这样您只需要构建WebUI.csproj。
https://stackoverflow.com/questions/42200188
复制相似问题