Skip to content

MSBuild don’ts


A couple of notes how NOT to use MSBuild.

  1. Don’t generate files with AssemblyInfo task. It screws comments, screws InternalsVisibleTo attributes, and whatever else it doesn’t account for.
    Instead
    : Use
    <FileUpdate Files="@(AssemblyInfoFiles)"
    Regex="AssemblyVersion\(".*?"\)\]"
    ReplacementText="AssemblyVersion("$(Major).$(Minor).$(Build).$(Revision)")]"
    />
    <FileUpdate Files="@(AssemblyInfoFiles)"
    Regex="AssemblyFileVersion\(".*?"\)\]"
    ReplacementText="AssemblyFileVersion("$(Major).$(Minor).$(Build).$(Revision)")]"
    />
  2. Don’t account for TfsXXXX community tasks – it won’t run on VS 2008 with Team Explorer 9.0.
    Instead:  Use <Exec Command=”tf …”>.
    And if you have domain authentication in TFS and don’t run integration under domain user (which happens), you even can’t run tf in cmd-line mode: stupid authentication dialog will pop up.
  3. Do not use local files to store version number. You will lose them when moving build to another host, so use only source control-dependent files.
    Might seem evident, but strange how many people miss this.
    So you’ll need to
    <Attrib Files="version.txt" Normal="true" />
  4. Per Scott Colestock’s post, “since TfsVersion interrogates the build server’s workspace, and BuildNumberOverrideTarget comes early in the process… you might find that you don’t get the changeset number you expect”.
  5. Don’t try to operate on XML node collections with tasks other then Xslt.
    For instance, XmlRead returns a Nodeset only as a string of “;”-joined
    Node.Value-s.
    XmlQuery supports Values property, though I wasn’t able to operate it’s results.
    Instead you can use ReadLinesFromFile (sadly, this will trim the lines).
    My personal choice for not-too-complex XML is… you can guess… yes, FileUpdate.
  6. Don’t use FtpUpload. It won’t create folders for you.
    Just <Exec> a ftp…
    By the way, Windows’ ftp.exe client is unable to upload in passive mode. You can download passively, if you issue “LITERAL PASV“, but it won’t help the client.

Post a Comment

Your email is never published nor shared.