Update build information with MSBuild error

All

I am trying to automatically update the assembly information of a project using the AssemblyInfo task, before assembly, however the target seems to do nothing (no crashes / errors), there is simply no update / create

Below is the build.proj file I am using (obviously some content changed)

Can anyone please 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>

      

0


source to share


1 answer


I think you did not specify the AssemblyInfoFiles specification in your AssemblyInfo task. This is what it looks like in 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>

      

First, we create a property that contains the name of the file that we will update. We have to do this with createItem because when we start building the file does not exist (and that's when MSBuild evaluates and defines in your build file.



Then we grab the readonly bit from the file.

Finally, we call the AssemblyInfo task, passing it the files to update and the custom assembly name we want to give (in this case, we put the TFS assembly label in the Assembly Description field so that we can easily tell the assembly assembly.

0


source







All Articles