简体   繁体   中英

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. However I need to import or somehow get to this information from every project file so I can set OutputName correctly.

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?

How about creating an altogether separate project just for loading this configuration stuff, and compiling it as a separate library / DLL? You could then use that DLL in each of the other projects where you need to import these settings.

It works using Import. I just had problems with VS2010 caching. See the linked issue for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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