How do you set the version of a C++/CLI project in Visual Studio?

时光怂恿深爱的人放手 提交于 2019-12-03 23:37:36

问题


I am working with a C++/CLI Project that wraps a C++ Native Library in Visual Studio 2012.

My C++/CLI Project has an AssemblyInfo.cpp. I set all the fields there, which include an "AssemblyVersionAttribute". However when I built my project and check its properties in the Windows Explorer, the version information is empty.

This is my first C++/CLI project, I have been going over all the options in the project properties but I couldn't find any that works for setting the version.

How do you set the version for a C++/CLI Project?


Update

I will add the content of my AssemblyInfo.cpp. I just filled in the fields that were present, this was automatically generated when I created the project.

using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;

[assembly:AssemblyTitleAttribute("MyTitle")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("")];
[assembly:AssemblyProductAttribute("MyProduct")];
[assembly:AssemblyCopyrightAttribute("Copyright © 2014")];
[assembly:AssemblyTrademarkAttribute("Inc")];
[assembly:AssemblyCultureAttribute("")];
[assembly:AssemblyVersionAttribute("3.9.0")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];

回答1:


The 'Details' page in Windows Explorer is pulling the information from unmanaged structures in the file, so you'll need to create an unmanaged version resource in order to fill that in.

  1. In Visual Studio, add a "Resource File (.rc)" to your project, if you don't already have one.
  2. In the resource file, add a new "Version" resource.
  3. Fill in your information.

I recommend that you maintain the various assembly attributes in your AssemblyInfo.cpp file as well. If you use reflection to get information about the assembly, it will use the stuff in AssemblyInfo.cpp, not in the version resource.




回答2:


There are two attributes; an AssemblyVersion attribute and an AssemblyFileVersion attribute. With the C# compiler, the file version will track the AssemblyVersion if an AssemblyFileVersion is not supplied. I can't recall if the C++/CLI compiler behaves differently, but it certainly is worth a shot to try AssemblyFileVersion.




回答3:


You can modify the VS_VERSION_INFO file inside the folder \app.rc\Version. You may use the Resource Visualizzation IDE to display this information file.



来源:https://stackoverflow.com/questions/23204774/how-do-you-set-the-version-of-a-c-cli-project-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!