Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net Visual Studio 2012中的配置管理是否与TargetFrameworkVersion有关?_.net_Visual Studio 2012 - Fatal编程技术网

.net Visual Studio 2012中的配置管理是否与TargetFrameworkVersion有关?

.net Visual Studio 2012中的配置管理是否与TargetFrameworkVersion有关?,.net,visual-studio-2012,.net,Visual Studio 2012,传统上,我习惯于在构建配置之间手动切换:调试、完整版本和精简版本。最后一个不仅排除了额外的函数,而且与.NET3.5兼容,而不是与常规的.NET4.5目标兼容。NET版本之间的切换也是通过手动完成的,这导致了项目的自动关闭和重新打开 随着项目规模的扩大,现在是将其拆分为多个部分的时候了。当然,手动切换一系列项目的配置和平台并不好笑,所以我编辑了.proj文件,并将TargetFrameworkVersion指令放入条件部分,就像这里和其他网站上的许多示例一样 <PropertyGroup

传统上,我习惯于在构建配置之间手动切换:调试、完整版本和精简版本。最后一个不仅排除了额外的函数,而且与.NET3.5兼容,而不是与常规的.NET4.5目标兼容。NET版本之间的切换也是通过手动完成的,这导致了项目的自动关闭和重新打开

随着项目规模的扩大,现在是将其拆分为多个部分的时候了。当然,手动切换一系列项目的配置和平台并不好笑,所以我编辑了.proj文件,并将
TargetFrameworkVersion
指令放入条件部分,就像这里和其他网站上的许多示例一样

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <DefineConstants>dotNet=4.5, HaveTesting=True, HaveDumper=True</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'RlzFull' ">
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <DefineConstants>dotNet=4.5, HaveTesting=False, HaveDumper=True</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'RlzLite' ">
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
    <DefineConstants>dotNet=3.5, HaveTesting=False, HaveDumper=False</DefineConstants>
</PropertyGroup>
<PropertyGroup  Condition=" '$(Configuration)' == 'Debug' ">
    <DebugType>full</DebugType>
    <DebugSymbols>true</DebugSymbols>
    <DefineDebug>true</DefineDebug>
    <DefineTrace>true</DefineTrace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' != 'Debug' ">
    <DebugType>none</DebugType>
    <DebugSymbols>false</DebugSymbols>
    <DefineDebug>false</DefineDebug>
    <DefineTrace>false</DefineTrace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <Prefer32Bit Condition=" $(TargetFrameworkVersion.Substring(1)) &gt;= 4.5 ">true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
    <PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x64' ">
    <PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
注意警告:对于一个实际上只引用了
System
System.Core
的简单库项目,日志表明它引用了几十个.NET库,包括我以前从未听说过的库。:-)

因此,问题是:是否真的可以在Visual Studio中随生成配置一起更改目标.NET版本,还是仅在手动运行MSBuild时才可以?我希望CLI和GUI中的体验应该是相同的。VisualStudio不具备在IDE中测试不同配置和轻松跟踪错误的能力,它不比带IntelliSense的记事本好多少

更新1。显然,GUI行为确实与CLI不一致:当我尝试使用分层
选择
-
时,当
-
否则
样式的条件项目描述时,IDE中的配置管理器根本就不再识别定义的配置和平台,显示“调试”和“任何CPU”(sic)作为每个项目的唯一选项。奇怪的是,当尝试使用.proj文件中已经定义的名称添加新配置或平台时,IDE确认该项已经存在


更新2。在以不同.NET版本为目标的配置之间切换(以上面清单中所示的方式进行描述)可能会导致Visual Studio 2012在每次尝试时崩溃。除非您想通过删除.suo文件来释放所有断点等,否则卸载除最简单的项目外的所有项目,然后切换配置可能会有所帮助,之后其他项目可能会安全地重新加载。另一个选项是编辑项目文件并临时排除指向以前版本的所有
TargetPlatformVersion
指令,然后将解决方案配置切换到安全值(例如“Debug”),然后恢复项目文件。

我在问题中提到的所有问题都证实了Visual Studio IDE的缺陷:

  • -将TargetFrameworkVersion从4.5切换到3.5会使从IDE编译变得不稳定
  • -IDE忽略“选择”中的项目配置和平台定义,否则会阻止
(回应的那个微软人不小心把他的答案互相交换了,所以不要混淆。)简言之,他们承认这样的行为不是故意的,但他们从未打算在CLI和IDE中实现相同的性能,也不会在可预见的新版本中实现,即使某些不一致可能导致IDE崩溃到完全不可用的程度

error BC30002: Type 'FooClass.BarClass' is not defined.
error BC30451: 'FooClass' is not declared. It may be inaccessible due to its protection level.
warning MSB3258: The primary reference "...\LibUtil.dll" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Windows.Forms, Version=4.0.0.0, ..." which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
warning MSB3268: The primary reference "...\LibUtil.dll" could not be resolved because it has an indirect dependency on the framework assembly "System.Web.ApplicationServices, Version=4.0.0.0, ..." which could not be resolved in the currently targeted framework.