none
per user variation for build

    Question

  • In microsoft.common.targets I found the following construct:
    <Import Project="$(MSBuildProjectFullPath).user" Condition="Exists('$(MSBuildProjectFullPath).user')"/>

    This made me assume that I can put a [csprojfile].user file in the folder where my csharp project file is located and then override common targets (like BeforeCompile)

    Unfortenately I don't get this scenario to work.
    Question: Is my assumption correct (assumptions are the mother of all ****-ups) and if so, why is msbuild not calling the targets in the .user file?

    Tnx,

    René
    Friday, December 09, 2005 3:02 PM

Answers

  • Visual Studio IDE uses .user files to store the shell settings, some source control settings, etc. I.e. this file cotains the configuration which is specific to a particular user. Due to this purpose of the file, I would not recommend to add any shared MSBuild code into this file. 
    But there is another option to override before/after targets specified in Microsoft.Common.Targets. You can create files called Custom.Before.Microsoft.Common.Targets and Custom.After.Microsoft.Common.Targets under $(ProgramFiles)\MSBuild\v2.0 folder. These files are imported in the beginning and in the end of Microsoft.Common.targets file. Or, as it was mentioned, you can import another project file from your project file.

    Friday, December 09, 2005 7:42 PM
    Moderator

All replies

  • Also notce that in that file the import statement is close to the top. Those targets BeforeBuild, BeforeCompile, etc are defined after that point. So it overwrites your implementation. You can use the .user file for properties and targets that are not defined in those files. I would suggest placing them in another file and importing that file after the import of the Micsoft.CSharp.targets file.

    Thanks,
    Sayed Ibrahim Hashimi
    Friday, December 09, 2005 7:03 PM
    Moderator
  • Visual Studio IDE uses .user files to store the shell settings, some source control settings, etc. I.e. this file cotains the configuration which is specific to a particular user. Due to this purpose of the file, I would not recommend to add any shared MSBuild code into this file. 
    But there is another option to override before/after targets specified in Microsoft.Common.Targets. You can create files called Custom.Before.Microsoft.Common.Targets and Custom.After.Microsoft.Common.Targets under $(ProgramFiles)\MSBuild\v2.0 folder. These files are imported in the beginning and in the end of Microsoft.Common.targets file. Or, as it was mentioned, you can import another project file from your project file.

    Friday, December 09, 2005 7:42 PM
    Moderator
  • Ok, that make sense.

    I thought of it as an way of building/compiling/testing my own temporary build additions which are not (yet) worth bothering the whole team with...

    I can however use the construct for the conditional import in the project file (and place it at the correct location in the project file)  and point to my own build file.
    As that build file won't exist on the build server things shouldn't break.

    Thanks for mentioning the  Custom.before.. and Custom.After... extension points. I didn't discover those yet. In my situation this won't do the trick as we are using a terminal server (and we therefore share the $(ProgramFiles)\MSBuild\v2.0 folder)).

    R.
    Friday, December 09, 2005 8:05 PM