Building Web Applications

Topics: For MSBee Users
Feb 2, 2007 at 3:58 PM
Converted a C# solution to VS2005 sp1, and successfully built it using MSBuild/MSBee and configured to run in VS2005 as and external tool. It was all very easy :)

I reconfigured the output directory to be ~/bin using the command line switch (/p:BaseFX1_1OutputPath=bin). Only problem I had was with a web application in the solution, where the build kept putting the output in the ~/bin/debug directory, instead of the ~/bin directory which is the norm for Web Applications.

This is because the MSBee common build file (MSBuildExtras.Fx1_1.Common.targets) doesn't seem to distinguish between web application projects and other projects so appends $(Configuration) on the end of the outputPath.

In the end I fixed by putting the following at the very end of the .csproj for the web application, just before the closing </project> tag.

<project ...
....
<PropertyGroup>
<OutputPath>$(BaseFX1_1OutputPath)</OutputPath>
<OutputPath Condition=" !HasTrailingSlash('$(OutputPath)') ">$(OutputPath)\</OutputPath>
<OutDir>$(OutputPath)</OutDir>
</PropertyGroup>
</project>

Has anyone else come accross this and/or know of a more elagant way of solving it?
Oct 3, 2007 at 8:37 PM
Is there such a thing as a .csproj for the web application? My VS2005 doesn't create one.
Oct 5, 2007 at 8:08 PM
VS2005 did not have a web application project when it was introduced. Later the "Web Application Project" was introduced as a seperate add-on, and not with Service Pack 1 for VS 2005 it is included.

HTH,
Ish
Oct 8, 2007 at 9:42 PM
Ish, thanks so much for your help on this. It's just what I needed.

Mark "catfood" from Cleveland, Ohio USA
Oct 11, 2007 at 5:05 PM
So here I am with the following results from running my build with diagnostics. It looks as though I am getting the C# compiler from .NET 2.0 as well as the runtime assemblies from .NET 2.0. See below for an excerpt from my .csproj file. Same result if I switch MSBee and "standard" CSharp.targets references.

I imagine I need to be using the C# compiler and runtime assemblies from .NET 1.1. Do you know what's going on?

Target "CoreCompile" in file "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.CSharp.targets":
Building target "CoreCompile" completely.
Output file "obj\Debug\TissService.dll" does not exist.
Using "Csc" task from assembly "Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "Csc"
Command:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702 /nostdlib- /errorreport:prompt
/warn:4 /baseaddress:285212672 /define:DEBUG;TRACE
/reference:C:\WINDOWS\assembly\GAC\Oracle.DataAccess\10.2.0.100__89b483f429c47342\Oracle.DataAccess.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll
/reference:C:\WINDOWS\assembly\GAC\Office\12.0.0.0__71e9bce111e9429c\Office.dll
/reference:C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Word\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll
/reference:C:\WINDOWS\assembly\GAC\Microsoft.Vbe.Interop\12.0.0.0__71e9bce111e9429c\Microsoft.Vbe.Interop.dll /debug+ /debug:full /filealign:4096
/optimize- /out:obj\Debug\TissService.dll /resource:obj\Debug\TissService.Global.resources /resource:obj\Debug\TissService.Tiss.resources /target:library
/warnaserror- AssemblyInfo.cs Global.asax.cs Tiss.asmx.cs
The "Csc" task is using "Csc.exe" from "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe".
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.42
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

Done executing task "Csc".

From the .csjproj file:

<EmbeddedResource Include="Tiss.asmx.resx">
<DependentUpon>Tiss.asmx.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\MSBee\MSBuildExtras.FX1_1.CSharp.targets" Condition=" '$(BuildingInsideVisualStudio)' == '' AND
'$(TargetFX11)'=='true'" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
Dec 2, 2008 at 1:27 PM
Mark - you need to rearrange the order between the import-tags. MSBUILD chooses the LAST assigned property when building, so you need to put the MSBEE-import AFTER the regular <import>-tag.
All according to the MSBEE-documentation :)

You have:
<Import Project="$(MSBuildExtensionsPath)\MSBee\MSBuildExtras.FX1_1.CSharp.targets" Condition=" '$(BuildingInsideVisualStudio)' == '' AND
'$(TargetFX11)'=='true'" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

You need:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\MSBee\MSBuildExtras.FX1_1.CSharp.targets" Condition=" '$(BuildingInsideVisualStudio)' == '' AND
'$(TargetFX11)'=='true'" />

(As a start, I would remove the import-conditions for the MSBEE-improt tag. If you get it working, you can put back the condition later. By doing this you make an easier  start..)