I've managed to solve this issue. I think it is a bug with the tools.
If you set the OutputPath
property to a relative path in the website.publishproj
file, then the AssemblyVersion
and AssemblyFileVersion
properties are not respected.
This is due to how this versioning works when merging website assemblies into one single assembly.
What happens is that an AssemblyInfo.cs
file is generated during the deploy and the supplied version numbers are inputted. This AssemblyInfo.cs
file is then compiled into an AssemblyInfo.dll
containing the version numbers you passed in.
Then aspnet_merge.exe
is called with the copyattrs
argument pointing to the AssemblyInfo.dll
it generated previously.
If you set OutputPath
to a relative path then this copyattrs
argument points to a dll that does not exist. This is because it is run from the path where the aspnet_merge.exe tool lives. Therefore a relative path back to the AssemblyInfo.dll
assembly does not find it's true location.
OutputPath
cannot be relative.
To fix the issue, I set mine to:
<PropertyGroup>
<OutputPath>$(MSBuildProjectDirectory)\..\..\TempPackageBuildDir\</OutputPath>
</PropertyGroup>
Why bother setting the OutputPath
at all?
When you do not set the OutputPath
it uses the temp directory in your environment variables. In my case, this would cause the build to fail, because the file lengths of some of the files were exceeding the 260 character windows limit (I have a very large website). The only way I could get it to build at all was to set the OutputPath
to a more shallow path.