Welcome to MSDN Blogs Sign in | Join | Help

MSBuild Sample Code Demonstrating How to Target 1.1 Framework with VS Whidbey Beta 2

<!--
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Written by Jomo Fisher
-->
<Project
 DefaultTargets="Build"
 xmlns="
http://schemas.microsoft.com/developer/msbuild/2003">

 <!--
 These two property groups inform VS that there is a Platform called .NET 1.1.
 --> 
 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|.NET 1.1' ">
  <DebugSymbols Condition="'$(DebugSymbols)'==''">true</DebugSymbols>
  <DebugType Condition="'$(DebugType)'==''">full</DebugType>
  <Optimize Condition="'$(Optimize)'==''">false</Optimize>
  <OutputPath Condition="'$(OutputPath)'==''">bin\.NET 1.1\Debug\</OutputPath>
  <DefineConstants Condition="'$(DefineConstants)'==''">DEBUG;TRACE</DefineConstants>
  <DefineConstants>$(DefineConstants);TARGETTING_FX_1_1</DefineConstants>
  <ErrorReport></ErrorReport>
  <WarningLevel Condition="'$(WarningLevel)'==''">4</WarningLevel>
  <UseHostCompilerIfAvailable>false</UseHostCompilerIfAvailable>
  <CscToolPath>$(SystemRoot)\Microsoft.NET\Framework\v1.1.4322</CscToolPath>
  <TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
 </PropertyGroup>

 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|.NET 1.1' ">
  <DebugType Condition="'$(DebugType)'==''">pdbonly</DebugType>
  <Optimize Condition="'$(Optimize)'==''">true</Optimize>
  <OutputPath Condition="'$(OutputPath)'==''">bin\.NET 1.1\Release\</OutputPath>
  <DefineConstants Condition="'$(DefineConstants)'==''">TRACE</DefineConstants>
  <DefineConstants>$(DefineConstants);TARGETTING_FX_1_1</DefineConstants>
  <ErrorReport></ErrorReport>
  <WarningLevel Condition="'$(WarningLevel)'==''">4</WarningLevel>
  <UseHostCompilerIfAvailable>false</UseHostCompilerIfAvailable>
  <CscToolPath>$(SystemRoot)\Microsoft.NET\Framework\v1.1.4322</CscToolPath>
  <TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
 </PropertyGroup>

 <!--
 Import the standard C# targets
 -->
 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

 <!--
 Now that the standard targets have been brought in. Override some properties
 and items it created.
 --> 
 <PropertyGroup>
  <AvailablePlatforms>$(AvailablePlatforms),.NET 1.1</AvailablePlatforms>

  <AssemblySearchPaths Condition=" '$(Platform)' == '.NET 1.1' ">
   {CandidateAssemblyFiles};
   $(ReferencePath);
   {HintPathFromItem};
   {TargetFrameworkDirectory};
   {AssemblyFolders};
   $(OutputPath);
   {GAC}
  </AssemblySearchPaths>

  <TargetFrameworkDirectory Condition=" '$(Platform)' == '.NET 1.1'">
   $(SystemRoot)\Microsoft.NET\Framework\v1.1.4322
  </TargetFrameworkDirectory>

 </PropertyGroup>

 <ItemGroup Condition=" '$(Platform)' == '.NET 1.1'">
  <TargetFrameworkDirectoryItem Include="$(SystemRoot)\Microsoft.NET\Framework\v1.1.4322">
   <InProject>false</InProject>
  </TargetFrameworkDirectoryItem>
 </ItemGroup>

 <!--
 Override this target from Microsoft.Common.Targets so that we can supply our own
 value for $(TargetFrameworkDirectory). This controls where assembly resolution
 logic finds FX assemblies.
 -->
 <Target
        Name="GetFrameworkPaths"
        DependsOnTargets="$(GetFrameworkPathsDependsOn)">

  <!-- Get the path to the target .NET framework directory. -->
  <GetFrameworkPath
   Condition=" '$(Platform)' != '.NET 1.1' ">
   <Output TaskParameter="Path" PropertyName="TargetFrameworkDirectory"/>
   <Output TaskParameter="Path" ItemName="TargetFrameworkDirectoryItem"/>
  </GetFrameworkPath>

  <!-- Get the path to the target .NET framework SDK directory. -->
  <GetFrameworkSDKPath
   Condition=" '$(Platform)' != '.NET 1.1' ">
   <Output TaskParameter="Path" PropertyName="TargetFrameworkSDKDirectory"/>
   <Output TaskParameter="Path" ItemName="TargetFrameworkSDKDirectoryItem"/>
  </GetFrameworkSDKPath>

 </Target>

 <!--
 For 1.1 builds, intercept the call to CorResGen target (which generates 2.0 resources) and
 slip in a call to our own CoreResGen_1_1.
 
 Handily, the devices version of the ResGen task is able to call the 1.1 version of
 ResGen directly.
 -->
 <UsingTask TaskName="CFResGen" AssemblyFile="$(MSBuildBinPath)\Microsoft.CompactFramework.Build.Tasks.dll" />
 <PropertyGroup Condition="'$(Platform)' == '.NET 1.1'">
  <ResGenDependsOn>ResolveAssemblyReferences;BeforeResGen;CoreResGen_1_1;AfterResGen</ResGenDependsOn>
 </PropertyGroup>
 <Target
        Name="CoreResGen_1_1"
        DependsOnTargets="$(CoreResGenDependsOn)">
  
  <CFResGen
            Condition = "
'@(ResxWithNoCulture)' != ''"
            Sources = "@(ResxWithNoCulture)"
            UseSourcePath = "$(UseSourcePath)"
            StateFile = "$(IntermediateOutputPath)$(MSBuildProjectFile).CrossCompileResGen.Cache"
            OutputResources = "@(ManifestResourceWithNoCultureName->'$(IntermediateOutputPath)%(Identity).resources')"
        >
   <!-- Appending to 'FilesWritten' list lets us be part of Clean and Incremental Clean. -->
   <Output TaskParameter = "FilesWritten" ItemName="FileWrites"/>
   <Output TaskParameter = "OutputResources" ItemName="ManifestResourceWithNoCulture"/>
  </CFResGen>

  <CFResGen
            Condition = "
'@(ResxWithCulture)' != ''"
            Sources = "@(ResxWithCulture)"
            UseSourcePath = "$(UseSourcePath)"
            StateFile = "$(IntermediateOutputPath)$(MSBuildProjectFile).CrossCompileResGen.Cache"
            OutputResources = "@(ManifestResourceWithCultureName->'$(IntermediateOutputPath)%(Identity).resources')"
        >
   <!-- Appending to 'FilesWritten' list lets us be part of Clean and Incremental Clean. -->
   <Output TaskParameter = "FilesWritten" ItemName="FileWrites"/>
   <Output TaskParameter = "OutputResources" ItemName="ManifestResourceWithCulture"/>
   
  </CFResGen>
 </Target>

</Project>

Published Friday, April 22, 2005 1:59 PM by Jomo Fisher

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Hack the Build: Use Whidbey Beta2 to target .NET Runtime 1.1

Jomo Fisher – A while back, I posted a sample that showed how to target the .NET 1.1 runtime with MSBuild....
Friday, April 22, 2005 2:48 PM by Hack the Build: Adventures in MSBuild

# re: MSBuild Sample Code Demonstrating How to Target 1.1 Framework with VS Whidbey Beta 2

On the off-chance, is it possible to show how this would be adapted to target Mono's framework (of some given version)?

Does this targetting prevent taking advantage of Custom Build Providers available in ASP.NET 2.0? (and do they respect this targetting?)
Saturday, April 30, 2005 1:02 AM by kfarmer

# How to create Framework 1.1 assembly using VS2005

Wednesday, June 08, 2005 5:33 AM by Ohad's WebLog

# How to create Framework 1.1 assembly using VS2005 for managed extentions

I have c++ Managed Extentions project written as framework 1.1 assmebly and i want to be able create it using VS2005.
do u have any clue about it?
Tuesday, January 03, 2006 8:50 AM by adi

# VSTS Jumpstart, things you will end up asking for

The following is my official VSTS jumpstart kit.&amp;nbsp; I will maintain this post entry going forward....
Wednesday, February 08, 2006 11:13 AM by Clark Sell

# VSTS Jumpstart, things you will end up asking for

Internet Links
Visual Studio Team System Home
Getting Started with Team Foundation
MSDN Technical...
Wednesday, February 08, 2006 10:18 PM by Clark Sell

# Using Compact Framework 1.1 with Visual Studio 2005

I was recently asked if it was possible to utilise Compact Framework 1.1 with VS2005.&amp;nbsp; I recollected...
Monday, May 08, 2006 2:31 PM by Dave Baker's WebLog

# Use Visual Studio 2005 for building Callouts!

You already can develop web services applications for CRM V3.0 using Visual Studio(VS) 2003 or 2005 (or...
Thursday, August 24, 2006 9:24 PM by Arash Ghanaie-Sichanie Blog

# re: MSBuild Sample Code Demonstrating How to Target 1.1 Framework with VS Whidbey Beta 2

This works great for VS2005.  I do have a question.  Do you know if it is possible to implement this kind of thing for VS2008?  It appears as though the MSBuild task framework is completely different in VS2008 and the resource generation no longer works.

Monday, December 03, 2007 5:52 PM by Martin Kramer

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker