简体   繁体   English

如何在多个项目之间共享属性/变量,同时又可以在一个地方进行编辑?

[英]How do you share properties/variables between multiple projects while being able to edit them in one place?

Currently I have this in multiple projects: 目前,我在多个项目中都有此功能:

<PropertyGroup>
    <InstallerMajorVersion>1</InstallerMajorVersion>
    <InstallerMinorVersion>09</InstallerMinorVersion>
    <InstallerBuildVersion>08</InstallerBuildVersion>
</PropertyGroup>
...
<PropertyGroup>
    <OutputName>Project-$(InstallerMajorVersion).$(InstallerMinorVersion).$(InstallerBuildVersion)</OutputName>
</PropertyGroup>

I'd like to have this information (the first PropertyGroup) in only one file, so I don't have to edit it in multiple places. 我只想在一个文件中拥有此信息(第一个PropertyGroup),因此不必在多个位置进行编辑。 However I need to import or somehow get to this information from every project file so I can set OutputName correctly. 但是,我需要从每个项目文件导入或以某种方式获取此信息,以便可以正确设置OutputName。

How do you share properties/variables between multiple projects? 如何在多个项目之间共享属性/变量?

I didn't have much luck with my <Import /> approach: VS2010 - Using <Import /> to share properties between setup projects? 我的<Import />方法不太运气: VS2010-使用<Import />在安装项目之间共享属性?

How about creating an altogether separate project just for loading this configuration stuff, and compiling it as a separate library / DLL? 如何创建一个完全单独的项目以仅用于加载此配置内容,并将其编译为单独的库/ DLL? You could then use that DLL in each of the other projects where you need to import these settings. 然后,您可以在需要导入这些设置的其他每个项目中使用该DLL。

It works using Import. 它可以使用导入工作。 I just had problems with VS2010 caching. 我刚在VS2010缓存中遇到问题。 See the linked issue for more details. 有关更多详细信息,请参见链接的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM