命名主程序集(.exe)以避免使用长文件名:Company.Product.Application.exe [英] Naming main assembly (.exe) to avoid long file name: Company.Product.Application.exe

查看:139
本文介绍了命名主程序集(.exe)以避免使用长文件名:Company.Product.Application.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

在创建通用类库时,我会镜像Microsoft .NET Framework名称结构,用我自己的公司名称(即Tek4.Net.NetworkWidget)替换System.

When creating general class libraries, I mirror the Microsoft .NET Framework name structure, replacing System with my own company name -- i.e., Tek4.Net.NetworkWidget.

对于特定于产品的程序集,我使用类似Tek4.ProductName.IO.FileWriter的东西.

For product-specific assemblies, I use something like Tek4.ProductName.IO.FileWriter.

输出.exe文件名太长!!! Company.Product.SuperApp.exe

Output .exe file names too long!!! Company.Product.SuperApp.exe

Visual Studio使用完整的程序集名称来输出文件;这对DLL来说很棒,但对控制台应用程序来说太过分了-即Tek4.Utils.ConsoleApp.exe

Visual Studio uses the full assembly name for output files; this is great for DLL's, but is too much for a console application -- i.e., Tek4.Utils.ConsoleApp.exe

主要可执行程序集的Forego层次结构名称:

Forego hierarchical names for main executable assemblies:

  • 程序集名称: ConsoleApp
  • EXE文件名: ConsoleApp.exe
  • Assembly name: ConsoleApp
  • EXE File name: ConsoleApp.exe

此解决方案意味着您提供的.exe文件将只包含一个简单的程序集名称,该名称无法很好地识别自身,并且更容易与其他程序集发生名称冲突.堆栈跟踪,.NET Reflector等仅显示ConsoleApp,而不显示标准的程序集名称.

This solution means your delivered .exe files will only contain a simple assembly name that fails to identify itself well, and is much more subject to name collisions with other assemblies. Stack traces, .NET Reflector, etc. will only show ConsoleApp instead of a fully-qualified assembly name.

编译后重命名输出文件,同时保留完整的内部程序集名称(使用生成后事件或手动重命名):

Rename the output file after compilation while retaining the full internal assembly name (using a post-build event or manual rename):

  • 程序集名称::Tek4.Utilities.ConsoleApp
  • EXE文件名: Tek4.Utilities.ConsoleApp.exe-> ConsoleApp.exe
  • Assembly name: Tek4.Utilities.ConsoleApp
  • EXE File name: Tek4.Utilities.ConsoleApp.exe --> ConsoleApp.exe

使用此解决方案名称时,不会发生冲突,并且在程序集名称出现的任何位置(即堆栈跟踪,系统事件日志等),都可以轻松地识别源.

With this solution name collision is unlikely, and anywhere the assembly name shows up (i.e., stack traces, system event logs, etc.) it is easy to identify the source.

由于某些原因,我仍然讨厌笨拙的手动重命名.

For some reason, I still hate the clunky manual rename, though.

非常感谢.

推荐答案

我还会使用较短的可执行文件名,特别是如果希望从命令行使用它的话.

I'd also go with the shorter executable name, especially if it is expected to be used from the command line.

话虽如此,但如果您同时拥有应用程序的GUI版本和命令行版本,那么我经常会看到以下约定:

Having that said, what I have seen quite often, is the following convention if you have both a GUI version and a command line version of your application:

GUI:SuperApp.exe 命令行:SuperApp.Console.exe

GUI: SuperApp.exe CLI: SuperApp.Console.exe

FWIW

这篇关于命名主程序集(.exe)以避免使用长文件名:Company.Product.Application.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆