开发者

Rename .NET 2.0 Executable

Does anyone know of any gotchas when changing a C# .NET 2.0 executable file name on a post build event, given that the executable is strong named and has an embedded manifest? Additionally, the executable will be signed by a third party before being packaged in a installer.

I know any associated .config files also need to be renamed to reflect the new executable name.

Am I also right in guessing that the best solution is to change the assembly name in the project properties, rather than renaming the executable file name? The problem is Visual Studio doesn't play ni开发者_如何转开发ce with conditional assembly names. (i.e. adding a condition attribute to the tag in the .csproj)


VS loads project once and then stores it in memory. If you want to build two assemblies from VS you can add AfterBuild target and call MSBuild to build your assembly again but with different parameters:

<ProperttyGroup Condition="'$(BuildAgain)'==''">
     <!-- Default parameters to VS -->
     <AssemblyName>Name1,Default</AssemblyName>   
<ProperttyGroup>

<ProperttyGroup Condition="'$(BuildAgain)'=='true'">
     <!-- Overrided parameters -->
     <AssemblyName>Name2.Custom</AssemblyName>   
<ProperttyGroup>

<Target Name="AfterBuild"
        Condition="'$(BuildAgain)'==''">
     <MSBuild Projects="$(MSBuildProjectFullPath)"
              Properties="BuildAgain=true;Configuration=$(Configuration);Platform=$(Platform)"
              Targets="Rebuild" 
</Target>


There is no real benefit to strong naming an exe. The benefit to strong naming a dll, is that someone cannot replace it with their own version of a malicious one (and you can put it in the GAC). Unless you are referencing your exe in another project as if it were a dll (which would be strange), you don't need to strong name it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜