Browse Source

Fixed SD2-474: Allow targeting other .NET Framework versions.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@549 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
2c1fdd4b8f
  1. 30
      src/AddIns/BackendBindings/CSharpBinding/Project/Resources/BuildOptions.xfrm
  2. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.cs
  3. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs
  4. 4
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs
  5. 7
      src/Libraries/ICSharpCode.Build.Tasks/Project/ICSharpCode.Build.Tasks.csproj
  6. 61
      src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.CSharp.targets
  7. 1
      src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.Common.targets
  8. 35
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs

30
src/AddIns/BackendBindings/CSharpBinding/Project/Resources/BuildOptions.xfrm

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
<Components version="1.0">
<System.Windows.Forms.UserControl>
<Name value="XmlUserControl1" />
<ClientSize value="{Width=527, Height=633}" />
<ClientSize value="{Width=527, Height=657}" />
<AutoScroll value="True" />
<Controls>
<System.Windows.Forms.GroupBox>
@ -68,16 +68,31 @@ @@ -68,16 +68,31 @@
<Name value="outputGroupBox" />
<Location value="{X=3,Y=161}" />
<Text value="${res:Dialog.ProjectOptions.Build.Output}" />
<Size value="{Width=521, Height=270}" />
<Size value="{Width=521, Height=299}" />
<TabIndex value="1" />
<Anchor value="Top, Left, Right" />
<Controls>
<System.Windows.Forms.ComboBox>
<Name value="targetFrameworkComboBox" />
<TabIndex value="8" />
<Size value="{Width=121, Height=21}" />
<DropDownStyle value="DropDownList" />
<Location value="{X=164,Y=112}" />
</System.Windows.Forms.ComboBox>
<System.Windows.Forms.Label>
<Name value="targetFrameworkLabel" />
<Location value="{X=13,Y=112}" />
<Text value="${res:Dialog.ProjectOptions.Build.TargetFramework}" />
<TextAlign value="MiddleRight" />
<Size value="{Width=150, Height=23}" />
<TabIndex value="7" />
</System.Windows.Forms.Label>
<System.Windows.Forms.GroupBox>
<Name value="advancedOutputGroupBox" />
<Location value="{X=6,Y=115}" />
<Location value="{X=6,Y=138}" />
<Text value="${res:Dialog.ProjectOptions.Build.Advanced}" />
<Size value="{Width=505, Height=149}" />
<TabIndex value="7" />
<Size value="{Width=505, Height=155}" />
<TabIndex value="9" />
<Anchor value="Top, Bottom, Left, Right" />
<Controls>
<System.Windows.Forms.ComboBox>
@ -157,7 +172,6 @@ @@ -157,7 +172,6 @@
<Name value="debugInfoComboBox" />
<TabIndex value="6" />
<Size value="{Width=121, Height=21}" />
<FormattingEnabled value="True" />
<DropDownStyle value="DropDownList" />
<Location value="{X=164,Y=88}" />
</System.Windows.Forms.ComboBox>
@ -213,7 +227,7 @@ @@ -213,7 +227,7 @@
</System.Windows.Forms.GroupBox>
<System.Windows.Forms.GroupBox>
<Name value="treatWarningsAsErrorsGroupBox" />
<Location value="{X=3,Y=523}" />
<Location value="{X=3,Y=552}" />
<UseCompatibleTextRendering value="True" />
<Text value="${res:Dialog.ProjectOptions.Build.TreatWarningsAsErrors}" />
<Size value="{Width=521, Height=100}" />
@ -255,7 +269,7 @@ @@ -255,7 +269,7 @@
</System.Windows.Forms.GroupBox>
<System.Windows.Forms.GroupBox>
<Name value="warningsGroupBox" />
<Location value="{X=3,Y=437}" />
<Location value="{X=3,Y=466}" />
<Text value="${res:Dialog.ProjectOptions.Build.ErrorsAndWarnings}" />
<Size value="{Width=521, Height=80}" />
<TabIndex value="2" />

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.cs

@ -29,6 +29,8 @@ namespace CSharpBinding.OptionPanels @@ -29,6 +29,8 @@ namespace CSharpBinding.OptionPanels
InitOutputPath();
InitXmlDoc();
InitTargetFramework(CSharpProject.DefaultTargetsFile,
@"$(SharpDevelopBinPath)\SharpDevelop.Build.CSharp.targets");
ConfigurationGuiBinding b;

4
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs

@ -50,10 +50,12 @@ namespace CSharpBinding @@ -50,10 +50,12 @@ namespace CSharpBinding
Create(info);
}
public const string DefaultTargetsFile = @"$(MSBuildBinPath)\Microsoft.CSharp.Targets";
protected override void Create(ProjectCreateInformation information)
{
base.Create(information);
imports.Add(@"$(MSBuildBinPath)\Microsoft.CSharp.Targets");
imports.Add(DefaultTargetsFile);
SetProperty("Debug", null, "CheckForOverflowUnderflow", "True", PropertyStorageLocations.ConfigurationSpecific);
SetProperty("Release", null, "CheckForOverflowUnderflow", "False", PropertyStorageLocations.ConfigurationSpecific);
}

4
src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs

@ -59,11 +59,13 @@ namespace VBNetBinding @@ -59,11 +59,13 @@ namespace VBNetBinding
IdGuid = BaseConfiguration["ProjectGuid"];
}
public const string DefaultTargetsFile = @"$(MSBuildBinPath)\Microsoft.VisualBasic.Targets";
public VBNetProject(ProjectCreateInformation info)
{
InitVB();
Create(info);
imports.Add(@"$(MSBuildBinPath)\Microsoft.VisualBasic.Targets");
imports.Add(DefaultTargetsFile);
}
public override ParseProjectContent CreateProjectContent()

7
src/Libraries/ICSharpCode.Build.Tasks/Project/ICSharpCode.Build.Tasks.csproj

@ -35,5 +35,10 @@ @@ -35,5 +35,10 @@
<Compile Include="Constants.cs" />
<Compile Include="MyToolTask.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="SharpDevelop.Build.CSharp.targets">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>
</Project>

61
src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.CSharp.targets

@ -0,0 +1,61 @@ @@ -0,0 +1,61 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- This file can be used to compile C# applications against other .NET Framework versions -->
<PropertyGroup Condition=" '$(TargetFrameworkVersion)' == 'v1.0' ">
<CscToolPath>$(SystemRoot)\Microsoft.NET\Framework\v1.0.3705</CscToolPath>
<SharpDevelopUse1xCompiler>true</SharpDevelopUse1xCompiler>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFrameworkVersion)' == 'v1.1' ">
<CscToolPath>$(SystemRoot)\Microsoft.NET\Framework\v1.1.4322</CscToolPath>
<SharpDevelopUse1xCompiler>true</SharpDevelopUse1xCompiler>
<!-- Work around MsBuild problem: Microsoft.CSharp.targets adds NoWarn entries that -->
<!-- don't exist in v1.1 when version is set to anything else than v1.0 -->
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(SharpDevelopUse1xCompiler)' == 'true' ">
<UseHostCompilerIfAvailable>false</UseHostCompilerIfAvailable>
<PlatformTarget/>
</PropertyGroup>
<!-- Use Microsoft's C# standard targets -->
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- Override properties created by Microsoft.CSharp.targets -->
<PropertyGroup Condition=" '$(SharpDevelopUse1xCompiler)' == 'true' ">
<AssemblySearchPaths>
{CandidateAssemblyFiles};
$(ReferencePath);
{HintPathFromItem};
{TargetFrameworkDirectory};
{AssemblyFolders};
$(OutputPath);
{GAC}
</AssemblySearchPaths>
<TargetFrameworkDirectory>$(CscToolPath)</TargetFrameworkDirectory>
</PropertyGroup>
<ItemGroup Condition=" '$(SharpDevelopUse1xCompiler)' == 'true' ">
<TargetFrameworkDirectoryItem Include="$(CscToolPath)">
<InProject>false</InProject>
</TargetFrameworkDirectoryItem>
</ItemGroup>
<!-- GetFrameworkPaths overwrites TargetFrameworkDirectory, so modify it -->
<!-- to be inactive if SharpDevelopUse1xCompiler is set. -->
<Target Name="GetFrameworkPaths" DependsOnTargets="$(GetFrameworkPathsDependsOn)">
<Error Condition=" ('$(SharpDevelopUse1xCompiler)' == 'true') And !Exists('$(CscToolPath)\Csc.exe') "
Text="Could not find the C# compiler in $(CscToolPath)."/>
<GetFrameworkPath Condition=" '$(SharpDevelopUse1xCompiler)' != 'true' ">
<Output TaskParameter="Path" PropertyName="TargetFrameworkDirectory"/>
<Output TaskParameter="Path" ItemName="TargetFrameworkDirectoryItem"/>
</GetFrameworkPath>
<GetFrameworkSDKPath Condition=" '$(SharpDevelopUse1xCompiler)' != 'true' ">
<Output TaskParameter="Path" PropertyName="TargetFrameworkSDKDirectory"/>
<Output TaskParameter="Path" ItemName="TargetFrameworkSDKDirectoryItem"/>
</GetFrameworkSDKPath>
</Target>
</Project>

1
src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.Common.targets

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Base file for compilers in custom backend bindinds -->
<UsingTask TaskName="Microsoft.Build.Tasks.CreateVisualBasicManifestResourceName" AssemblyName="Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

35
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs

@ -169,5 +169,40 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -169,5 +169,40 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
}
};
}
protected void InitTargetFramework(string defaultTargets, string extendedTargets)
{
const string TargetFrameworkProperty = "TargetFrameworkVersion";
debugInfoBinding = helper.BindStringEnum("targetFrameworkComboBox", TargetFrameworkProperty,
"",
new StringPair("", "Default (.NET 2.0)"),
new StringPair("v1.0", ".NET 1.0"),
new StringPair("v1.1", ".NET 1.1"),
new StringPair("v2.0", ".NET 2.0"));
debugInfoBinding.CreateLocationButton("targetFrameworkLabel");
helper.Saved += delegate {
// Test if SharpDevelop-Build extensions are needed
MSBuildProject project = helper.Project;
bool needExtensions = false;
PropertyStorageLocations location;
foreach (string configuration in project.GetConfigurationNames()) {
foreach (string platform in project.GetPlatformNames()) {
string value = project.GetProperty(configuration, platform, TargetFrameworkProperty, "", out location);
if (value.Length > 0) {
needExtensions = true;
}
}
}
for (int i = 0; i < project.Imports.Count; i++) {
if (needExtensions) {
if (defaultTargets.Equals(project.Imports[i], StringComparison.InvariantCultureIgnoreCase))
project.Imports[i] = extendedTargets;
} else {
if (extendedTargets.Equals(project.Imports[i], StringComparison.InvariantCultureIgnoreCase))
project.Imports[i] = defaultTargets;
}
}
};
}
}
}

Loading…
Cancel
Save