5

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>Images\RegularIcon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Customer|AnyCPU' ">
    ...blah...
    <ApplicationIcon>Images\CustomerIcon.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>Images\foo.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.

4

2 に答える 2

5

おそらく実際に機能します。なかなか見られないものばかりです。Windows エクスプローラーには、プログラムのアイコンをアイコン キャッシュに保存するという非常に厄介な習慣があります。したがって、1 つのアイコンで .exe を実行すると、そのアイコンがキャッシュに保存されます。後で再び必要になったときにいつでもすぐに利用できるようにします。最適化、.exe ファイルからアイコンを掘り出すのは遅いです。

キャッシュをリセットすることは可能ですが、面倒です。適切な手順については、superuser.com に問い合わせてください。または、Visual Studio で確認してください。[ファイル] + [開く] + [ファイル] を選択し、.exe を選択して [アイコン] ノードを開き、エントリをダブルクリックします。

于 2012-05-25T18:29:14.150 に答える