Updating Assembly information with MSBuild failing

All

i am trying to automatically update the assembly information of a project using AssemblyInfo task, before build however the target appears to do nothing (no failure/error) just no update/creation

Below is the build.proj file I am using (obviously some contents altered)

Can anyone help?

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build"  
         xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets"/>
  <PropertyGroup>
    <Major>1</Major>
    <Minor>0</Minor>
    <Build>0</Build>
    <Revision>0</Revision>
  </PropertyGroup>
  <PropertyGroup>
    <BuildDir>C:\svn\Infrastructure</BuildDir>
  </PropertyGroup>

  <ItemGroup>
    <SolutionsToBuild Include="Infrastructure.sln"/>
  </ItemGroup>

  <Target Name="Build" DependsOnTargets="ChangeDataAccessAssemblyInfo">
    <RemoveDir Directories="$(BuildDir)\Builds" Condition="Exists('$(BuildDir)\Builds')" />
    <MSBuild Projects="@(SolutionsToBuild)" Properties="Configuration=Debug" Targets="Rebuild" />
  </Target>

  <ItemGroup>
    <TestAssemblies Include="Build\Logging\Logging.UnitTests.dll" />
  </ItemGroup>

  <!--<UsingTask TaskName="NUnit" AssemblyFile="$(teamcity_dotnet_nunitlauncher_msbuild_task)" />
  <Target Name="Test" DependsOnTargets="Build">
    <NUnit NUnitVersion="NUnit-2.4.6" Assemblies="@(TestAssemblies)" />
  </Target>-->

  <Target Name="ChangeDataAccessAssemblyInfo" >
    <Message Text="Writing ChangeDataAccessAssemblyInfo file for 1"/>
    <Message Text="Will update $(BuildDir)\DataAccess\My Project\AssemblyInfo.vb" />
    <AssemblyInfo CodeLanguage="VB"
       OutputFile="$(BuildDir)\DataAccess\My Project\AssemblyInfo_new.vb"                
       AssemblyTitle="Data Access Layer"
       AssemblyDescription="Message1"
       AssemblyCompany="http://somewebiste"
       AssemblyProduct="the project"
       AssemblyCopyright="Copyright notice"
       ComVisible="true"
       CLSCompliant="true"
       Guid="hjhjhkoi-9898989"
       AssemblyVersion="$(Major).$(Minor).1.1"
       AssemblyFileVersion="$(Major).$(Minor).5.7"
       Condition="$(Revision) != '0' "
       ContinueOnError="false" />

    <Message Text="Updated Assembly File Info" 
             ContinueOnError="false"/>
  </Target>  
</Project>

Answers


I think you are missing the specification of the AssemblyInfoFiles attribute on your AssemblyInfo task. Here's how it looks on a project I'm working on...

<Target Name="AfterGet">
	<Message Text="In After Get"/>

	<CreateItem Include="$(SolutionRoot)\Source\SomeProject\My Project\AssemblyInfo.vb">
		<Output ItemName="AssemblyInfoFiles" TaskParameter="Include"/>
	</CreateItem>

	<Attrib Files="@(AssemblyInfoFiles)"
            ReadOnly="false"/>

	<AssemblyInfo AssemblyInfoFiles="@(AssemblyInfoFiles)"
        AssemblyDescription="$(LabelName)">
	</AssemblyInfo>
</Target>

What we're doing is first using to create a property that contains the name of the file we'll be updating. We have to do this via createItem because when we start the build the file doesn't exist (and that is when MSBuild evaluates the and definitions in your build file.

We then take the readonly bit off the file.

Finally we invoke the AssemblyInfo task passing it the file(s) to update and a custom assembly name that we want to give it (in this case we put the TFS build label into the Assembly Description field so that we can easily tell which team build the assembly came from.


Need Your Help

Gtk# NodeView colored rows

c# monodevelop gtk#

I use NodeView object to output data to user in this way (Gtk# tutorial):

H1 Bottom Border Underline

html css

I am having an issue where I am trying to underline my h1 with a border-bottom, but it extends behind my picture (to the left). I would like the underline to extend to the very end of the page. Her...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.