MSBee FX1_1 output path should be optional

Topics: For MSBee Users
Aug 17, 2006 at 12:16 AM
migrated from power toy forums
originally posted by RikoE
------------------------------------------------------

I can see the need to output the .NET 1.1 code to a different output folder than the normal .NET 2.0 assemblies (bin\Debug\FX11 if "BaseFX11OutputPath" is not specified), but shouldn't this be an optional setting?

I am adapting MSBee for my company to build .NET 1.1 code with Visual Studio 2005 (we have created custom templates that do not create partial classes and points to the MSBee targets), but I have found that I have to manually comment out the section in the MSBee common target file that specifies the FX1_1 folder (etc.) for output. We just want to build our solution normally with 1.1 assemblies in the bin and obj folders, and if we want to change to .NET 2.0 will probably just remove the reference to the MSBee target files.

I find it restrictive that MSBee builds to different folders by default, and that it is not easy to make .NET 1.1 builds behave like normal builds in Visual Studio. This does not fit in with the rest of the extensibility model of MSBuild and MSBee.

Is it conceivable to make the FX1_1 output folders optional by specifying an output switch, rather than by having to specify a different path on the command line of msbuild, which is not possible from inside Visual Studio? Now that I want to distribute MSBee and the templates to the rest of the team, I find that I have to download the source, change the target file and repackage the whole thing. I would prefer no to do this, as we then have a custom version of MSBee which we need to maintain.

Riko Eksteen
Aug 17, 2006 at 12:17 AM

originally posted by Alan J. McFarlane
------------------------------------------------------

Knowing nothing about nothing, neither what you are doing is a 'good thing' or not, nor much else...

Nor how you import the MSBee targets, but assuming you import the MSBee target into a .SLN or .*PROJ file etc can't you put a MSBuild element of the following form before the import:

<PropertyGroup>
<BaseFX11OutputPath Condition=" '$(BaseFX11OutputPath)' == '' ">bin\</BaseFX1_1OutputPath>
</PropertyGroup>

That will (I hope) stop BaseFX11OutputPath from defaulting within MSBuildExtras.Fx11.Common.targets

Alan
Aug 17, 2006 at 12:17 AM
originally posted by Alan J. McFarlane
------------------------------------------------------

(Of course not in a .SLN file...)
Aug 17, 2006 at 12:17 AM
originally posted by RikoE
------------------------------------------------------

This is exactly my problem. It isn't possible to do what you suggested, as this bit of code from MSBuildExtras.FX1_1.Common.targets show:

<Choose>
<When Condition=" '$(BaseFX1_1OutputPath)' == '' ">
<PropertyGroup>
<OutputPath>bin\FX1_1\</OutputPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<OutputPath>$(BaseFX1_1OutputPath)</OutputPath>
...
</PropertyGroup>
</Otherwise>
</Choose>

Basically, there's a default, and the only way not to have the default, is by explicitly specifying a different path. Now what if you want to default to the path the user sets in Visual Studio's property screen for a project? No easy way to do that... in fact, I can't figure out how to do it at all, which meant I had to comment out the above code from the MSBee target file.
Aug 17, 2006 at 12:17 AM
originally posted by John DAddamio - MSFT
------------------------------------------------------

Actually, the bit of code you quoted demonstrates that it is entirely possible to do as Alan J. McFarlane suggested in an earlier post. That is the purpose of that section of code and the BaseFX1_1OutputPath property.

When I insert the following code into a VB project file for one of the test projects included in the MSBee test suite:

<PropertyGroup>
<BaseFX11OutputPath>$(OutputPath)</BaseFX11OutputPath>
</PropertyGroup>

between the Import for Microsoft.VisualBasic.targets and the Import for MSBuildExtras.FX1_1.VisualBasic.targets and then build with MSBee as follows:

msbuild /p:TargetFX1_1=true VBConsoleApp.vbproj

I see the following extract in the console output:

"Target CopyFilesToOutputDirectory:
Copying file from "obj\FX1_1\Debug\VBConsoleApp.exe" to "bin\Debug\VBConsoleApp.exe"."

Similarly, when I built the solution which has multiple projects, the VBConsoleApp.exe went to bin\Debug and the output of the other projects went to \bin\FX1_1\Debug.

So, If you want to use the path the user sets for a project, you can insert a setting of the BaseFX11OutputPath property between the Import for Microsoft.VisualBasic.targets and the Import for MSBuildExtras.FX11.VisualBasic.targets.

Another alternative would be to create your own customized import file which supports all the languages you need to use. There's an example of this under the Mixed-Language Solutions section in the MSBee Readme doc. The file imports the appropriate MSBee taget file for the language of the project currrently being compiled. You could add the setting of the BaseFX1_1OutputPath property to that customized import file before the importation of the MSBee taget file

This customized import file would be imported in your projects instead of the MSBee taget file for the language. This way, your developers would only have to import one file regardless of which language they were using and would not have to explicitly set the BaseFX1_1OutputPath property themselves.
Aug 17, 2006 at 12:17 AM
originally posted by RikoE
------------------------------------------------------

Thanks for the answer John.

Why is it necessary to go to these lengths to get the default path though? Surely a default path is just that - a path that is used when no other is specified.

It just seems the wrong way round to me - having to specify that the default path should be used, instead of using the BaseFX1_1OutputPath property if you don't want to use the default path.
Aug 17, 2006 at 12:17 AM
originally posted by Alan J. McFarlane
------------------------------------------------------

Well think of us users of MSBee using it for its designed purpose -- to allow users of VS2005 to build projects upgraded from VS2003 for both FXv2 and FXv1.1. Then the default path is absolutely required. Otherwise we'd have both versions being built into .\bin. Yikes! Assuming I'm understanding what you are suggesting... :-)

Alan
Aug 17, 2006 at 12:18 AM
originally posted by John DAddamio - MSFT
------------------------------------------------------

Alan's right. That's exactly why we decided to have MSBee default to a path different than when building under VS 2005 or from the command line with the standard msbuild!

Often users want to be able to build their software so that one build targets NDP 2.0 and the other targets NDP 1.1; That seems to be the more usual case than wanting to go to the project's default output path...

John
Aug 17, 2006 at 12:18 AM
originally posted by RikoE
------------------------------------------------------

I'll admit, that's a good answer :-)

With the supplied workaround of setting the BaseFX1_1OutputPath property to be equal to OutputPath I suppose one can make it work.

The only catch is that when importing the MSBee targets file it will replace the OutputPath property with the default for BaseFX1_1OutputPath without the user even knowing about it.

The way the MSBee help document suggests of doing this is to import the MSBee targets file only when the FX1_1 property is set. This is usable when using MSBee from the command-line, but there is no way to set that property when building inside Visual Studio.

I realise the MSBee team offers no support for its use from inside the IDE, but you have to admit that switching to the command-line every time you want to build the .NET 1.1 version of your project is a bit of a pain.

In that case I would be more in favour of an approach where extra configurations or platforms are created for the .NET 1.1 version of the project, and it can be built be setting the configuration on the command line instead of using the FX11 and BaseFX11OutputPath properties. A configuration or platform supports the idea of a separate output path and is selectable from inside the IDE. In fact, I think that is the approach used by Jomo Fisher for his CrossCompile C# targets (http://blogs.msdn.com/jomo_fisher/archive/2005/04/22/410903.aspx).

Mind you, I'm not trying to tell you how to implement MSBee, these are just suggestions for how I think it could be made more usable.

Riko