Freigeben über


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

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

    <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

<PropertyGroup>
<CompileDependsOn>$(CompileDependsOn);Compile_1_1</CompileDependsOn>
</PropertyGroup>

    <Target
Name="MainBuiltProjectOutputGroup_1_1"
Outputs="@(TargetName11->'%(FullPath)')">

       <CreateItem Include="bin\$(Configuration)(1_1)\$(TargetFileName)">
<Output TaskParameter="Include" ItemName="TargetName11" />
</CreateItem>

 <Message Text="==>@(TargetName11)"/>
</Target>

    <Target
Name="ResolveProjectReferences_1_1"
Condition="<'@(MSBuildProjectReference)'!=''>">

 <!--Build the referenced project. -->
<MSBuild
Projects="@(MSBuildProjectReference)"
Targets="Build"
Condition="'$(BuildingInsideVisualStudio)'!='true'"/>

 <!-- Get project to project references. -->
<MSBuild
Projects="@(MSBuildProjectReference)"
Targets="MainBuiltProjectOutputGroup_1_1">

             <Output TaskParameter="TargetOutputs" ItemName="ResolvedProjectReferencePaths11"/>

        </MSBuild>

    </Target>

    <Target
Name="ResolveAssemblyReferences_1_1">

 <!-- Rebase each FX assemblies to their 1_1 version -->
<CreateItem
Include="@(ReferencePath)"
Condition="'$(TargetFrameworkDirectory)\%(FileName)'=='%(RootDir)%(Directory)%(FileName)'">
<Output TaskParameter="Include" ItemName="FrameworkReferencePath" />
</CreateItem>

 <CreateItem
Include="@(FrameworkReferencePath->'$(SystemRoot)\Microsoft.NET\Framework\v1.1.4322\%(FileName)%(Extension)')">
<Output TaskParameter="Include" ItemName="AssemblyReferencePaths11" />
</CreateItem>

    </Target>

    <Target
Name="ResolveReferences_1_1"
DependsOnTargets="ResolveProjectReferences_1_1;ResolveAssemblyReferences_1_1"/>

<Target
Name="CopyLocalProjectReferences_1_1">

        <Copy
SourceFiles="@(ResolvedProjectReferencePaths11)"
DestinationFolder="bin\$(Configuration)(1_1)"
SkipUnchangedFiles="true"
Condition="<'@(ResolvedProjectReferencePaths11)'!=''>"
/>

    </Target>

    <Target
Name="Compile_1_1"
Condition="'$(BuildingProject)'=='true'"
DependsOnTargets="MainBuiltProjectOutputGroup_1_1;ResolveReferences_1_1;CopyLocalProjectReferences_1_1"
>

 <!-- Create the output folder. -->
<MakeDir Directories="@(TargetName11->'%(RootDir)%(Directory)')"/>

 <!-- Compile the assembly. -->
<Csc
AdditionalLibPaths="$(AdditionalLibPaths)"
AddModules="@(AddModules)"
AllowUnsafeBlocks="$(AllowUnsafeBlocks)"
BaseAddress="$(BaseAddress)"
CheckForOverflowUnderflow="$(CheckForOverflowUnderflow)"
CodePage="$(CodePage)"
DebugType="$(DebugType)"
DefineConstants="$(DefineConstants);TARGETTING_FX_1_1"
DelaySign="$(DelaySign)"
DisabledWarnings="$(NoWarn)"
DocumentationFile="$(DocFile)"
EmitDebugInformation="$(DebugSymbols)"
ErrorReport="$(ErrorReport)"
FileAlignment="$(FileAlignment)"
GenerateFullPaths="$(GenerateFullPaths)"
KeyContainer="$(KeyContainerName)"
KeyFile="$(KeyOriginatorFile)"
LangVersion="$(LangVersion)"
MainEntryPoint="$(StartupObject)"
NoConfig="true"
NoLogo="$(NoLogo)"
NoStandardLib="$(NoStdLib)"
Optimize="$(Optimize)"
OutputAssembly="@(TargetName11)"
Platform="$(PlatformTarget)"
References="@(AssemblyReferencePaths11);@(ResolvedProjectReferencePaths11)"
Resources="@(ManifestResourceWithNoCulture);@(ManifestNonResxWithNoCultureOnDisk);@(CompiledLicenseFile)"
Sources="@(Compile)"
TargetType="$(OutputType)"
ToolPath="$(SystemRoot)\Microsoft.NET\Framework\v1.1.4322"
TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
UseHostCompilerIfAvailable="$(UseHostCompilerIfAvailable)"
Utf8Output="$(Utf8Output)"
WarningLevel="$(WarningLevel)"
WarningsAsErrors="$(WarningsAsErrors)"
WarningsNotAsErrors="$(WarningsNotAsErrors)"
Win32Icon="$(ApplicationIcon)"
Win32Resource="$(Win32Resource)"
/>

    </Target>

</Project>

Comments