添加编译参数,使用Visual Studio IDE CSC命令 [英] Add compile parameter to csc command using Visual Studio IDE

查看:372
本文介绍了添加编译参数,使用Visual Studio IDE CSC命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该解决方案由两个项目: main.csproj helper.csproj

The solution consists of two projects: main.csproj and helper.csproj.

什么Id'like来使用DLL文件,做帮手项目将被编译成,为 main.dll

What Id'like to do is using dll which helper project will be complied into, as an embedded resource for main.dll.

有关的目的,这是似乎合理的添加自定义编译属性的项目 /资源:其中,对DLL和路径GT;

For that purposes it's seems resonable to add custom compile attribute for project main: /resource: <path to dll>.

现在的问题是我无法找到如何通过项目属性添加此编译参数。

The problem is I can't find how to add this compile parameter through the Project Property.

PS也许有人可以建议其他的解决办法,以避免在编译过程中更改。

PS Maybe someone can suggest other solution to avoid making changes in compile process.

推荐答案

您应该能够辅助集添加作为main.csproj资源。这将使的MSBuild生成 CSC 正确的参数。

You should be able to add the helper assembly as a resource in the main.csproj. That will make MsBuild generate the correct parameters for csc.

(的MSBuild是一般可达使用.NET和包括4.x和也使用的VisualStudio构建引擎。)

(MsBuild is the build engine used by .NET in general up to and including 4.x and is also used by VisualStudio.)

你能做些什么来设置它是:

What you can do to set this up is:

  • 右键点击的项目在Visual Studio解决方案资源管理器中,选择的添加现有项目的。添加该组件被嵌入的辅助项目的bin文件夹链接项。 (点击小箭头的添加的在选择对话框按钮,进入添加为链接的选项)。
  • 在以嵌入式资源的属性,在工程项目,设置的动作
  • Right click the Main project in the Visual Studio solution explorer and select Add existing item. Add the assembly to be embedded as a linked item from the bin folder of the helper project. (click the little arrow on the Add button in the selection dialog to access the option to add as a link).
  • In the properties for the item in the Main project, set Action to Embedded resource.

整蛊位将让您有调试版本或取决于你正在建设什么样的配置发布版本包含了正确的版本。 如果你需要,你可以:

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:

  • 编辑main.csproj文件,包括为帮助程序DLL的路径 $ {配置} 变量。
  • 添加pre-生成步骤的main.csproj文件中的程序集复制到一个固定的地方,包括从那里(中的包括作为链接的位置不再需要的文件当时的)
  • edit main.csproj file to include the ${Configuration} variable in the path for the helper dll.
  • Add a pre-build step to the main.csproj file to copy in the assembly to a fixed place and include the file from there (the include as link bit is no longer needed then)

为确保您始终建立辅助组件,当你建立了主要部件,我会建议你添加一个项目引用的主要项目。

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.

这篇关于添加编译参数,使用Visual Studio IDE CSC命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆