在Visual Studio和Unity中使用MDB文件进行构建后事件 [英] Post-build events with MDB files in Visual Studio and Unity
问题描述
我在Unity中实现MonoBehaviours的源代码不是Assets文件夹中的脚本,而是我作为插件添加的已编译DLL.
My source code for my MonoBehaviours in Unity is not scripts inside the Assets folder, but compiled DLL's that I add as Plugins.
我在Visual Studio中为我的C#项目添加了构建后事件,以尝试在每次更改内容时都必须复制DLL文件和MDB文件来解决这个问题.
I have added post-build events in Visual Studio for my C# project, to try to get around the work with having to copy the DLL file and the MDB file every time I've changed something.
copy /Y "$(TargetDir)$(ProjectName).dll" "$(SolutionDir)\..\Assets\Plugins\$(ProjectName).dll"
copy /Y "$(TargetDir)$(ProjectName).dll.mdb" "$(SolutionDir)\..\Assets\Plugins\$(ProjectName).dll.mdb"
它的工作原理就像一种魅力……几乎.我遇到的问题是,将生成DLL,然后运行此命令,但是MDB文件还没有时间更新,所以我将一个旧的MDB文件复制到Assets/Plugins文件夹中.
It works like a charm... almost. The problem I'm encountering, is that the DLL builds, then this command is run, but the MDB file hasn't had time to update yet, so I get an old MDB file copied to the Assets/Plugins folder.
有没有办法在复制MDB文件之前等待它更新?
Is there a way to wait for the MDB file to update before copying it?
推荐答案
我现在有可行的解决方案.基本上,复制DLL和MDB文件是从C#项目属性中的PDB文件生成MDB文件作为构建目标的过程的一部分,在构建过程中,直到MonoMdbGenerator完成执行之后,才执行复制./p>
I now have solution that works. Basically, the copying of the DLL and MDB files is part of the process of generating the MDB file from the PDB file in my C# project properties, as build targets, where the copy won't be performed until the MonoMdbGenerator is done executing.
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild">
<CallTarget Targets="GenerateMonoSymbols" Condition=" Exists('$(OutputPath)\$(AssemblyName).pdb') " />
</Target>
<Target Name="GenerateMonoSymbols">
<Message Text="$(ProjectName) -> $(TargetPath).mdb" Importance="High" />
<Exec Command="$(MonoMdbGenerator) $(AssemblyName).dll" WorkingDirectory="$(MSBuildProjectDirectory)\$(OutputPath)" />
<CallTarget Targets="CopyDLL" />
</Target>
<Target Name="CopyDLL">
<Copy SourceFiles="$(OutputPath)\$(AssemblyName).dll" DestinationFolder="$(SolutionDir)..\Assets\Plugins\$(ProjectName)" />
<Copy SourceFiles="$(OutputPath)\$(AssemblyName).dll.mdb" DestinationFolder="$(SolutionDir)..\Assets\Plugins\$(ProjectName)" />
</Target>
有关该主题的一些好读物:
Some good reads on the subject:
- https://msdn.microsoft.com/en-us/library/ms366724.aspx
- https://msdn.microsoft.com/en-us/library/3e54c37h.aspx
- https://msdn.microsoft.com/en-us/library/ms366724.aspx
- https://msdn.microsoft.com/en-us/library/3e54c37h.aspx
这篇关于在Visual Studio和Unity中使用MDB文件进行构建后事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!