locked
changing properties in csproj files RRS feed

  • Question

  • how do change properties in <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> section of a csproj file using tfsbuild.

    i want to change the debugtype and some others.
    Wednesday, August 5, 2009 9:13 PM

Answers

  • Hi,

    Here's a solution using the File.RegEx from the SDC Tasks (http://www.codeplex.com/sdctasks) to replace the PublishURL in the project file. 

    First you would want to make the project file writeable, then change it.  This won't be checked in.  If you want it to be checked in, let me know.

    I hope this helps,

    Mike


      <Target Name ="BeforeCompile">
        <Message Text="In Before Compile"/>

        <Message Text="Making csproj file writable"/>
        <Exec Command="attrib -R &quot;$(SolutionRoot)\MySolution\MyProject.csproj&quot;"/>

        <Message Text="Replacing PublishUrl"/>
        <File.RegEx
          Path="$(SolutionRoot)\MySolution\MyProject.csproj"
          RegularExpression="&lt;PublishUrl&gt;(.*?)&lt;/PublishUrl&gt;"
          NewValue="&lt;PublishUrl&gt;$(PublishUrl)&lt;/PublishUrl&gt;"
           />
      </Target>


    blog - http://www.codesmartnothard.com
    Thursday, August 6, 2009 3:03 PM
  • Hi simps,

    Csproj file is a MSBuild format file, and an XML file in fact, you can modify it with many editors except VS.

    1 Check out .csproj file with Team Explorer.
    2 Make the project file writeable.
    3 Open the file with notepad and change the debugtype or some others.
    4 Save the file .
    5 Check in .csproj file with Team Explorer.

    If there is any problem, please feel free to tell me .

    Best Regards.

    Ruiz
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Sincerely, Ruiz Yi
    Monday, August 10, 2009 3:10 AM
    Moderator

All replies

  • The csproj is an xml file and can be adjusted by the Xml tasks in the MSBuildExtension


    Ewald - Please remember to mark the replies as answers if they help.
    http://www.ewaldhofman.nl
    Wednesday, August 5, 2009 9:54 PM
  • I take it the csproj is in your SolutionsToBuild collection. You can pass metadata into that collection. See this article: http://msdn.microsoft.com/en-us/library/bb399127.aspx

    Mike
    Wednesday, August 5, 2009 9:59 PM
  • Hi,

    Here's a solution using the File.RegEx from the SDC Tasks (http://www.codeplex.com/sdctasks) to replace the PublishURL in the project file. 

    First you would want to make the project file writeable, then change it.  This won't be checked in.  If you want it to be checked in, let me know.

    I hope this helps,

    Mike


      <Target Name ="BeforeCompile">
        <Message Text="In Before Compile"/>

        <Message Text="Making csproj file writable"/>
        <Exec Command="attrib -R &quot;$(SolutionRoot)\MySolution\MyProject.csproj&quot;"/>

        <Message Text="Replacing PublishUrl"/>
        <File.RegEx
          Path="$(SolutionRoot)\MySolution\MyProject.csproj"
          RegularExpression="&lt;PublishUrl&gt;(.*?)&lt;/PublishUrl&gt;"
          NewValue="&lt;PublishUrl&gt;$(PublishUrl)&lt;/PublishUrl&gt;"
           />
      </Target>


    blog - http://www.codesmartnothard.com
    Thursday, August 6, 2009 3:03 PM
  • Hi simps,

    Csproj file is a MSBuild format file, and an XML file in fact, you can modify it with many editors except VS.

    1 Check out .csproj file with Team Explorer.
    2 Make the project file writeable.
    3 Open the file with notepad and change the debugtype or some others.
    4 Save the file .
    5 Check in .csproj file with Team Explorer.

    If there is any problem, please feel free to tell me .

    Best Regards.

    Ruiz
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Sincerely, Ruiz Yi
    Monday, August 10, 2009 3:10 AM
    Moderator