Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
252 views
in Technique[技术] by (71.8m points)

c# - Set a different ApplicationIcon for each build configuration

I'm trying to set a different Icon for each build configuration of my C# project (using VS 2010 pro). One config is for a different customer, thus that config should use a different icon.

I'm not sure why this doesn't work in the csproj file:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    ...blah...
    <ApplicationIcon>ImagesRegularIcon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Customer|AnyCPU' ">
    ...blah...
    <ApplicationIcon>ImagesCustomerIcon.ico</ApplicationIcon>
</PropertyGroup>

It doesn't work. Not really sure if I'm on the right track.

One frustrating thing... if I set the icon in Visual Studio with in the Properties->Application tab, it creates this in the csproj file:

<PropertyGroup>
    <ApplicationIcon>Imagesfoo.ico</ApplicationIcon>
</PropertyGroup>

Why does the icon specified in this anonymous PropertyGroup get obeyed, but the one in my conditional PropertyGroup get ignored?

I appreciate any help with this one.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It probably actually does work. It is just something you can't easily see. Windows Explorer has this really awkward habit of storing icons for programs in the icon cache. So if you run an .exe with one icon then it stores the icon in the cache. To be available quickly later whenever it is needed again. An optimization, digging an icon out of an .exe file is slow.

Resetting the cache is possible but is awkward, best to ask at superuser.com for a good procedure. Or just check it with Visual Studio. File + Open + File, select the .exe, open the Icons node and double-click the entry.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...