[英]C# Adding a reference to a class in another project without referencing the project
[英]How to have a Project Reference without referencing the actual binary
以下工作正常,但不会复制Asp.net Core 2.0项目的.pdb文件。
<ProjectReference Include="..\ProjectA\ProjectA.csproj">
<Project>{b402782f-de0a-41fa-b364-60612a786fb2}</Project>
<Name>ProjectA</Name>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<OutputItemType>Content</OutputItemType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Targets>Build;DebugSymbolsProjectOutputGroup</Targets>
</ProjectReference>
那么,我们应该如何复制pdb文件呢?
那么,我们应该如何复制pdb文件呢?
正如Marc和bolg指出的那样, 此方法在Visual Studio中无法复制.pdb文件。 因为我们将<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
为项目引用,而不引用实际的二进制文件,所以VS / MSBuild不会复制.pdb文件。
许多人问到除了.exe / .dll之外,还如何复制.pdb文件。 事实证明,这是一个技巧, 但在VS中构建时不起作用 。 但这是可以的,因为在VS中您实际上并不需要.pdb,因为调试器无论如何都会在其原始路径中找到.pdb。
如果仍要复制此.pdb文件,则可以为项目使用MSBuild复制任务或构建事件 :
MSBuild复制任务:
为此,请卸载您的项目。 然后在项目的最后,在end-tag之前,放在脚本下面:
<Target Name="CopyPDBfile" AfterTargets="Build">
<Copy SourceFiles="$(SolutionDir)ProjectA\bin\Debug\ProjectA.pdb" DestinationFolder="$(TargetDir)" />
</Target>
构建事件:
在Pre-build / Post-build事件中添加以下构建命令行:
xcopy /y "$(SolutionDir)ProjectA\bin\Debug\ProjectA.pdb" "$(TargetDir)"
注意:不要在构建命令行中忽略双引号和空格。
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.