Question

I'm using the publish to file-system option in Visual Studio, and I'd like the publish process to automatically append the assembly version-number to the output directory when I publish a project.

Google just isn't getting me the answer.

Is this possible? How-to?

Was it helpful?

Solution

I would get the assembly version as described in the following posts:

MSBuild Task to read version of dll

Access Version from AssemblyInfo in MSBuild

As follows[Altered version of the code as described in the given links]:

 <PropertyGroup>
     <AssemblyList>myfolder\myLibrary.dll</AssemblyList>
 </PropertyGroup>

 <Target Name="AssemblyInformations">
   <GetAssemblyIdentity
    AssemblyFiles="$(AssemblyList)">
  <Output
      TaskParameter="Assemblies"
      ItemName="AssemblyInfos"/>
</GetAssemblyIdentity>

<Message Text="Files: %(AssemblyInfos.Version)"/>

And then I would use something like the following to create a directory in the place you want to publish:

    <CreateProperty Value="$(Public_Shared_Folder)$(ProjectName)\">
  <Output TaskParameter="Value" PropertyName="PublicFolderToDropZip" />
</CreateProperty>
<MakeDir Directories="$(PublicFolderToDropZip)" Condition="$(Configuration)=='Release' And !Exists('$(PublicFolderToDropZip)')" />

The entire operation can be completely automated.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top