-2

I am publishing dotnet core app like this:

call dotnet publish MyApp.csproj -c Release -o "%scriptDir%\..\dist\Publish\MyApp" -r win10-x64

My ".csproj" file includes this (VersionInfo.cs file):

  <ItemGroup>
    <Compile Include="..\VersionInfo.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
  </ItemGroup>

It contains info like this:

[assembly: AssemblyVersion("1.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyCompany("My Company")]
[assembly: AssemblyCopyright("Copyright © My Company 2018")]
[assembly: AssemblyTrademark("My Company")]

And in the output "MyApp.dll" gets all of this information: versions, company name and etc. set in file properties. But generated runtime executable "MyApp.exe" doesn't have any Version Info :(.

  • Why doesn't the runtime contain the same info as the DLL?
  • How do I add the info from the "VersionFile.cs" file to the specified runtime executable?
Chezzwizz
  • 415
  • 5
  • 7
Drasius
  • 825
  • 1
  • 11
  • 26

2 Answers2

1

There is much easier way to include assembly information within project file.

<PropertyGroup>
    <AssemblyVersion>1.0</AssemblyVersion>
    <FileVersion>1.0.0.0</FileVersion>
    <Company>My Company</Company>
    <Copyright>Copyright © My Company 2018</Copyright>
    <Trademark>My Company</Trademark>
</PropertyGroup>

As an example you can take a look into Newtonsoft.Json project file.

Here you can find some discussion about how .NET Core exe files are working.

Overall:

  • .NET Core does not support exe files by design, only dll is generated
  • If you specify runtime identifier during publish then native host (exe for windows) will be generated to boot managed dll for particular OS
Mike
  • 3,766
  • 3
  • 18
  • 32
  • 2
    I can totally agree on this answer. Don't use VersionInfo.cs with dotnet core – MUG4N Jun 08 '18 at 17:06
  • Main thing that I use this VersionFile in all projects, and there is there is "VersionUpdater" app which updates that VersionInfo.cs (Version and other details) and it is included in to all projects. I think I can use same approach which project "targets", yes? Maybe have some example? And also not sure if it helps (as DLL has info, but "MyApp.exe" does not info...). – Drasius Jun 09 '18 at 06:40
  • Checked. Including "PropertyGroup" parameters instead of "VersionInfo.cs" file does not help. "MyApp.exe" properties still is not populated, only DLL, so there is no difference using one or another. Not an answer. – Drasius Jun 09 '18 at 09:01
  • 1
    @Drasius "MyApp.exe" is not a managed application it is a native wrapper to boot your managed DLL. That is how .NET Core standalone application are working – Mike Jun 09 '18 at 14:04
  • @MikeMazmanyan so there no way to add same version info for executable? – Drasius Jun 11 '18 at 05:46
  • @Drasius yea, it's just a native wrapper. Why do you need version info with executable ? It's stored within the DLL even if you generate executable. – Mike Jun 11 '18 at 13:19
  • @MikeMazmanyan it is not big deal, but mostly you check executable for details. And was interesting is it posiible or not. as when you do full .NET version build which MSBuild all that info is available/set on the executable. – Drasius Jun 12 '18 at 14:01
0

I was able to solve this by setting the GenerateAssemblyInfo tag in .csproj to true.

<PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <OutputType>WinExe</OutputType>
    <GenerateAssemblyInfo>true</GenerateAssemblyInfo> <!-- this was false -->
...
  </PropertyGroup>
A. Niese
  • 399
  • 3
  • 13