Pregunta

Is it possible to extract the version number from an ASP.NET MVC 4.0 Web application's MSDeploy generated package?

One method to determine the version number dynamically is to use reflection as shown below but this requires the application to have been installed on the server.

System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()

I need to source the version number directly from the MSDeploy package.

Thanks,
F.

¿Fue útil?

Solución

It's possible. The deployment package is just a zip file. If you're using .NET 4.5 you can unzip the file using ZipFile. Then you'll want to either, look at the archive.xml file to find the correct path (replacing C:\ with C_C) inside the Content folder, or you can traverse the Content folder.

From there, you should be able to find your bin folder, with your assemblies. You can get the version by:

var assembly = AssemblyName.GetAssemblyName("{path to assembly}");
var assemblyVersion = assembly.Version;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top