我是一名有用的助手,可以为您进行文本翻译。
我正在开发一个ASP.Net Core项目,其中.csproj文件如下所示:
当这个应用程序发布到Windows系统时,我可以从其属性中获取版本信息。如上所述,显示为17.12.1。
或者,我可以在命令提示符中运行wmic datafile where name="filepath/app.exe" get Version /value命令,以获取相同的版本信息。
我正在开发一个ASP.Net Core项目,其中.csproj文件如下所示:
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>dummyapp</AssemblyName>
<Version>17.12.1</Version>
<RuntimeIdentifiers>centos.7-x64;win7-x64</RuntimeIdentifiers>
</PropertyGroup>
当这个应用程序发布到Windows系统时,我可以从其属性中获取版本信息。如上所述,显示为17.12.1。
或者,我可以在命令提示符中运行wmic datafile where name="filepath/app.exe" get Version /value命令,以获取相同的版本信息。
但是在Linux发行版中有没有标准的方法来获取相同的内容呢?
我已经研究过:
经过所有的尝试,似乎我需要在.csproj
文件中实现其他内容,以便使用bash获取版本信息。有人可以指出需要做什么,或者给出一个提示吗。
Main
方法:
public static void Main(string[] args)
{
var root = new Root();
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(SettingsFilename, optional: false,
reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
config.Bind(root);
//some codes
var host = new WebHostBuilder()
.UseKestrel()
.UseUrls(root.AppUrl)
.UseConfiguration(config)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.ConfigureServices(s =>
s.AddRouting().DetectTokenChange(config))
.UseSetting(WebHostDefaults.ApplicationKey, "dummyapp")
.Configure(app => app.UseRouter(r => r.MapPost("dumptoqueue",
async (context) =>
await Task.Run(() => AddtoQueue(context)))))
.Build();
host.Run();
}
使用命令行构建的应用程序:
dotnet publish -c release -r centos.7-x64
--version
不是strings
的一部分吗?我之前尝试过并在帖子中也提到了。如果您指的是其他内容,请明确指出。 - boop_the_snootMain
代码(如果它是用 C# 编写的)并解释你的构建过程来实现。你需要更好地了解你的编译过程,并在你的问题中提供它。因此,请编辑你的问题以改进它。更多地介绍你在 Linux 上使用的编译器,并解释如何从源代码构建可执行文件。你用什么命令进行构建? - Basile StarynkevitchMain
没有使用args
?为什么呢? - Basile Starynkevitch