通过使用不同的项目配置打靶多个.NET Framework版本 [英] Targetting multiple .net framework versions by using different project configurations

查看:155
本文介绍了通过使用不同的项目配置打靶多个.NET Framework版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我需要建立在两种不同的配置项目。一个配置将针对.NET Framework 3.5的,另外将针对.NET框架4.0。 首先,这可能吗? 我创建了一个名为DotNet35(使用通常的步骤),这将面向.NET 3.5的新配置。我已经通过指定所创建的项目配置为V3.5目标版本做到了这一点 它似乎并没有工作。知道为什么吗?下面是我的.csproj属性组部分 (仅适用于手动添加的是TargetFrameworkVersion元素)

 <的PropertyGroup条件='$(配置)| $(平台)'=='DotNet35 |值为anycpu'>
    < D​​ebugSymbols>真< / DebugSymbols>
    < OutputPath> BIN \ DotNet35 \< / OutputPath>
    < D​​efineConstants>调试; TRACE< / DefineConstants>
    < D​​EBUGTYPE>全< / DEBUGTYPE>
    < TargetFrameworkVersion> V3.5< / TargetFrameworkVersion>
    < PlatformTarget>值为anycpu< / PlatformTarget>
    <$c$cAnalysisLogFile>..\..\bin\Client\Debug\CS.XRAY.XRayClient.dll.$c$cAnalysisLog.xml</$c$cAnalysisLogFile>
    &LT; codeAnalysisUseTypeNameInSup pression&GT;真&LT; / codeAnalysisUseTypeNameInSup pression&GT;
    <$c$cAnalysisModuleSup$p$pssionsFile>GlobalSup$p$pssions.cs</$c$cAnalysisModuleSup$p$pssionsFile>
    &LT; GenerateSerializationAssemblies&GT;关机&LT; / GenerateSerializationAssemblies&GT;
    &LT; ErrorReport&GT;提示&LT; / ErrorReport&GT;
    &LT; codeAnalysisRuleSet&GT; AllRules.ruleset&LT; / codeAnalysisRuleSet&GT;
    &LT; codeAnalysisRuleSetDirectories取代; C:\ Program Files文件\微软的Visual Studio 10.0 \团队TOOLS \静态分析工具\\规则集&LT; / codeAnalysisRuleSetDirectories&GT;
    &LT; codeAnalysisIgnoreBuiltInRuleSets&GT;真&LT; / codeAnalysisIgnoreBuiltInRuleSets&GT;
    &LT; codeAnalysisRuleDirectories取代; C:\ Program Files文件\微软的Visual Studio 10.0 \团队TOOLS \静态分析工具\ FxCop的\\规则&LT; / codeAnalysisRuleDirectories&GT;
    &LT; codeAnalysisIgnoreBuiltInRules&GT;真&LT; / codeAnalysisIgnoreBuiltInRules&GT;
  &LT; /的PropertyGroup&GT;
 

解决方案

我不认为你可以做到这一点在同一个项目的多个配置。

您可以做到这一点,但是,通过让多个项目文件,每个文件针对不同架构的版本。

编辑:,以做到这一点,最简单的方法,顺便说一句就是只复制当前项目的文件,打开它,并更改目标框架版本

I have a project which i need to build in two different configurations. One configuration will target .net framework 3.5 and another will target .net framework 4.0. First of all is that possible? I have created a new configuration called DotNet35 (using the usual steps) which will target .net 3.5. I have done this by specifying the target version in the created project config as v3.5 It does not seem to work. Any idea why? Here is the property group section from my .csproj (only manual addition is the TargetFrameworkVersion element)

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DotNet35|AnyCPU'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\DotNet35\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <CodeAnalysisLogFile>..\..\bin\Client\Debug\CS.XRAY.XRayClient.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
    <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
    <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
    <CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
    <CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
    <CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
    <CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
  </PropertyGroup>

解决方案

I do not think you can do that with multiple configuration of the same project.

You can do that, though, by having multiple project files, each one targeting a different framework version.

EDIT: The easiest way to do that, btw is to just copy your current project file, open it, and change the targeted framework version.

这篇关于通过使用不同的项目配置打靶多个.NET Framework版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆