TargetFramework只能在項目文件中進行配置,並不能作爲一個開關CSC.EXE過去了,看到設置TargetFrameworkVersion和TargetFrameworkProfile在下面的例子
所以要動態設置的唯一方法是修改項目文件與下面的設置,如果你想設置客戶端配置文件與CSC.EXE編譯
靶向.NET Framework 4.0客戶端配置文件
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A5F58561-47CA-482A-83E0-1D43C312B0A7}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleApplication1</RootNamespace>
<AssemblyName>ConsoleApplication1</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
靶向的.NET Framework 4.0
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A5F58561-47CA-482A-83E0-1D43C312B0A7}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleApplication1</RootNamespace>
<AssemblyName>ConsoleApplication1</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile></TargetFrameworkProfile>
</PropertyGroup>
你能更具體嗎? –
@JohnSaunders請參閱編輯 – ikh
你能否正確配置你的.csproj並使用msbuild? –