VS 构建后事件
我想实现一个执行以下操作的构建后事件
- DLL 输出的相对路径副本(1 个文件,不是所有调试 jazz)
- 将输出 DLL 注册到 GAC
这是如何完成的?
I would like to implement a post build event that performs the following actions
- A relative path copy of the DLL output (1 file, not all the debug jazz)
- A register the output DLL to GAC
How is this done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
你想要那个吗?
(输入到项目属性下的构建后步骤字段中)
Does that do you want?
(Entered into the field for post-build step under project properties)
在“项目属性 -> 构建事件 -> 发布构建事件命令行:”中输入以下内容,
或将以下代码段添加到项目(例如 csproj)文件中
请注意,建议在复制命令参数周围添加“”以避免路径问题包含空格。 另请注意,可以使用 && 组合多个命令。
Enter following into "Project properties->Build events->Post build events command line:"
or add following snippet to project (e.g. csproj) file
Note that it is recommended to add "" around copy command arguments to avoid problems with paths containing whitespaces. Also note that multiple commands can be combined using &&
您确定要将此作为编译的一部分吗? 如果可以避免的话,我建议在解决方案中使用项目参考而不是 GAC。 复制文件是一回事,但在 GAC 中注册相当具有侵入性,您可能需要考虑编译代码的其他环境。例如其他开发人员的计算机、测试环境/构建服务器等。如果您有构建服务器实际上,您应该将 NAnt 之类的东西与某种持续集成服务器一起使用。
Are you sure you want to do this as part of a compile? I would recommend using project references in solutions rather than the GAC if you can avoid it. Copying files is one thing, but registering in the GAC is fairly intrusive and you may want to consider the other environments your code is compiled in. Things like other developers' machines, and test environments/build servers etc. If you have a build server really you should be using something like NAnt with some sort of continuous integration server.
我遇到了同样的问题,并且我花了一些功夫才能使其发挥作用。
就我而言,我想做另一种方式,即将 SDL dll 复制到我的输出文件夹中。
请注意,
$(Configuration)
将是您的输出文件夹(例如“调试”或“发布”)。引号是我所缺少的,显然当右侧以
\
结尾时您需要它们。 因此,始终使用它们可能会更安全。希望能为别人节省5分钟!
PS我使用Visual Studio 2010
I had to same issue and I struggled a bit to make it works.
In my case, I wanted to do the other way around which is copying the SDL dll into my output folder.
Note that,
$(Configuration)
will be your output folder (e.g. Debug or Release).The quotes was what I was missing, apparently you need them when the right hand side end with a
\
. Thus, it might be safer to always use them.Hope to save someone else a 5 minutes!
P.S. I use Visual Studio 2010
你可能想看看 MS Build。 这是我们在工作中使用的。
CodeProject 链接 &
MSDN 参考
you may want to look at MS Build. Its what we use here at work.
CodeProject Link &
MSDN Ref
对于问题中的步骤 2,我似乎更喜欢以下内容:
注意:这需要 Windows SDK 将安装在您的开发计算机上。
有关可用宏的详细信息,例如 MSDN 上的 $(TargetPath)。
For step 2 in the question I seem to prefer the following:
Note: this requires the Windows SDK to be installed on your development machine.
More info on the available macros, such as $(TargetPath), on MSDN.
这个问题很老了。 最简单的方法是在 .csproj 文件中添加类似的内容。 例如,我正在虚拟机上运行一些测试,很高兴在编译后将其发送给虚拟机:
This question is old. The easiest way is to add something like this on your .csproj file. For example I am running some tests on a virtual machine and its nice to have it sent to it after I compile:
遇到了一个相关问题。 这里的答案有帮助(谢谢!)。
我的场景是在调试依赖 MEF 的应用程序时,我需要将相关 DLL 放在特定位置。 我遇到了覆盖先前构建的问题,因此确实需要向脚本添加删除。
希望对某人也有帮助!
Ran into a related issue. The answers here helped (thanks!).
My scenario was in debugging an MEF-reliant application I needed to have the related DLLs in a particular location. I ran into issue with overwriting the prior build so did need to add a delete to the script.
Hope that helps someone, too!