[英]Add compile parameter to csc command using Visual Studio IDE
The solution consists of two projects: main.csproj
and helper.csproj
. 该解决方案包含两个项目:
main.csproj
和helper.csproj
。
What Id'like to do is using dll which helper
project will be complied into, as an embedded resource for main.dll
. Id想要做的是使用将被编译到
helper
项目中的dll作为main.dll
的嵌入式资源。
For that purposes it's seems resonable to add custom compile attribute for project main
: /resource: <path to dll>
. 为此,为项目
main
添加自定义编译属性似乎是合理的: /resource: <path to dll>
。
The problem is I can't find how to add this compile parameter through the Project Property. 问题是我找不到如何通过项目属性添加此编译参数。
PS Maybe someone can suggest other solution to avoid making changes in compile process. PS也许有人可以建议其他解决方案,以避免在编译过程中进行更改。
You should be able to add the helper assembly as a resource in the main.csproj. 您应该能够将辅助程序程序集作为资源添加到main.csproj中。 That will make MsBuild generate the correct parameters for
csc
. 这将使MsBuild为
csc
生成正确的参数。
(MsBuild is the build engine used by .NET in general up to and including 4.x and is also used by VisualStudio.) (MsBuild是.NET之前(包括4.x以及更高版本)通常使用的生成引擎,VisualStudio也使用它。)
What you can do to set this up is: 您可以设置以下内容:
Main
project in the Visual Studio solution explorer and select Add existing item . Main
项目,然后选择“ 添加现有项” 。 Add the assembly to be embedded as a linked item from the bin folder of the helper project. Main
project, set Action to Embedded resource . Main
项目中项目的属性中,将“操作”设置为“ 嵌入式资源” 。 Tricky bit would be to include the correct build so that you include the debug build or the release build depending on what configuration you are building. 棘手的一点是要包括正确的版本,以便根据要构建的配置来包含调试版本或发行版本。 If you need that, you can either:
如果需要,您可以:
${Configuration}
variable in the path for the helper dll. ${Configuration}
变量包含在帮助程序dll的路径中。 To make sure you always build the helper assembly when you build the main assembly I would recommend you add a project reference to the main project. 为了确保在构建主程序集时始终构建辅助程序集,建议您向主项目添加项目引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.