Note that there are some explanatory texts on larger screens.

plurals
  1. POvisual studio 2010 compiler conditions based on target framework
    primarykey
    data
    text
    <p>I need to be able to do this in my code:</p> <pre><code>#if NET_3_5 // .net 3.5 only code #else // non .net 3.5 code #endif </code></pre> <p>Based on <a href="https://stackoverflow.com/questions/3436526/detect-target-framework-version-at-compile-time/3437249#3437249">this</a>, I tried adding this to my csproj file, but it didn't help:</p> <pre><code>&lt;DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v3.5' "&gt;NET_3_5&lt;/DefineConstants&gt; </code></pre> <h1>update</h1> <p>Here's the project file:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt; &lt;PropertyGroup&gt; &lt;Configuration Condition=" '$(Configuration)' == '' "&gt;Debug&lt;/Configuration&gt; &lt;Platform Condition=" '$(Platform)' == '' "&gt;AnyCPU&lt;/Platform&gt; &lt;ProductVersion&gt;8.0.30703&lt;/ProductVersion&gt; &lt;SchemaVersion&gt;2.0&lt;/SchemaVersion&gt; &lt;ProjectGuid&gt;{FAA16900-38B9-4891-86C3-F595DA1FA6F7}&lt;/ProjectGuid&gt; &lt;OutputType&gt;Library&lt;/OutputType&gt; &lt;AppDesignerFolder&gt;Properties&lt;/AppDesignerFolder&gt; &lt;RootNamespace&gt;RavenLinqpadDriver&lt;/RootNamespace&gt; &lt;AssemblyName&gt;RavenLinqpadDriver&lt;/AssemblyName&gt; &lt;TargetFrameworkVersion&gt;v3.5&lt;/TargetFrameworkVersion&gt; &lt;FileAlignment&gt;512&lt;/FileAlignment&gt; &lt;TargetFrameworkProfile /&gt; &lt;/PropertyGroup&gt; &lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "&gt; &lt;DebugSymbols&gt;true&lt;/DebugSymbols&gt; &lt;DebugType&gt;full&lt;/DebugType&gt; &lt;Optimize&gt;false&lt;/Optimize&gt; &lt;OutputPath&gt;bin\Debug\&lt;/OutputPath&gt; &lt;DefineConstants&gt;DEBUG;TRACE&lt;/DefineConstants&gt; &lt;DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v3.5' "&gt;NET_3_5&lt;/DefineConstants&gt; &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt; &lt;WarningLevel&gt;4&lt;/WarningLevel&gt; &lt;/PropertyGroup&gt; &lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "&gt; &lt;DebugType&gt;pdbonly&lt;/DebugType&gt; &lt;Optimize&gt;true&lt;/Optimize&gt; &lt;OutputPath&gt;bin\Release\&lt;/OutputPath&gt; &lt;DefineConstants&gt;TRACE&lt;/DefineConstants&gt; &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt; &lt;WarningLevel&gt;4&lt;/WarningLevel&gt; &lt;/PropertyGroup&gt; &lt;PropertyGroup&gt; &lt;SignAssembly&gt;true&lt;/SignAssembly&gt; &lt;/PropertyGroup&gt; &lt;PropertyGroup&gt; &lt;AssemblyOriginatorKeyFile&gt;RavenLinqpadDriverStrongNameKey.pfx&lt;/AssemblyOriginatorKeyFile&gt; &lt;/PropertyGroup&gt; &lt;ItemGroup&gt; &lt;Reference Include="GalaSoft.MvvmLight"&gt; &lt;HintPath&gt;..\packages\MvvmLight.3.0.3\lib\net35\GalaSoft.MvvmLight.dll&lt;/HintPath&gt; &lt;/Reference&gt; &lt;Reference Include="GalaSoft.MvvmLight.Extras"&gt; &lt;HintPath&gt;..\packages\MvvmLight.3.0.3\lib\net35\GalaSoft.MvvmLight.Extras.dll&lt;/HintPath&gt; &lt;/Reference&gt; &lt;Reference Include="LINQPad"&gt; &lt;HintPath&gt;..\lib\LINQPad.exe&lt;/HintPath&gt; &lt;Private&gt;False&lt;/Private&gt; &lt;/Reference&gt; &lt;Reference Include="Newtonsoft.Json.Net35"&gt; &lt;HintPath&gt;..\lib\Newtonsoft.Json.Net35.dll&lt;/HintPath&gt; &lt;/Reference&gt; &lt;Reference Include="PresentationCore" /&gt; &lt;Reference Include="PresentationFramework" /&gt; &lt;Reference Include="Raven.Client.Lightweight-3.5"&gt; &lt;HintPath&gt;..\lib\Raven.Client.Lightweight-3.5.dll&lt;/HintPath&gt; &lt;/Reference&gt; &lt;Reference Include="System" /&gt; &lt;Reference Include="System.ComponentModel.DataAnnotations" /&gt; &lt;Reference Include="System.Core" /&gt; &lt;Reference Include="System.Windows.Interactivity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"&gt; &lt;HintPath&gt;..\packages\MvvmLight.3.0.3\lib\net35\System.Windows.Interactivity.dll&lt;/HintPath&gt; &lt;/Reference&gt; &lt;Reference Include="System.Xml.Linq" /&gt; &lt;Reference Include="System.Data.DataSetExtensions" /&gt; &lt;Reference Include="System.Data" /&gt; &lt;Reference Include="System.Xml" /&gt; &lt;Reference Include="WindowsBase" /&gt; &lt;/ItemGroup&gt; &lt;ItemGroup&gt; &lt;Compile Include="GuidValueConverter.cs" /&gt; &lt;Compile Include="RavenDriver.cs" /&gt; &lt;Compile Include="Properties\AssemblyInfo.cs" /&gt; &lt;Compile Include="RavenConectionDialog.xaml.cs"&gt; &lt;DependentUpon&gt;RavenConectionDialog.xaml&lt;/DependentUpon&gt; &lt;/Compile&gt; &lt;Compile Include="RavenConnectionInfo.cs" /&gt; &lt;Compile Include="RavenContext.cs" /&gt; &lt;Compile Include="Utility.cs" /&gt; &lt;/ItemGroup&gt; &lt;ItemGroup&gt; &lt;None Include="packages.config" /&gt; &lt;None Include="RavenLinqpadDriverStrongNameKey.pfx" /&gt; &lt;/ItemGroup&gt; &lt;ItemGroup&gt; &lt;Content Include="header.xml"&gt; &lt;CopyToOutputDirectory&gt;Always&lt;/CopyToOutputDirectory&gt; &lt;/Content&gt; &lt;/ItemGroup&gt; &lt;ItemGroup&gt; &lt;Page Include="RavenConectionDialog.xaml"&gt; &lt;SubType&gt;Designer&lt;/SubType&gt; &lt;Generator&gt;MSBuild:Compile&lt;/Generator&gt; &lt;/Page&gt; &lt;/ItemGroup&gt; &lt;Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /&gt; &lt;PropertyGroup&gt; &lt;PostBuildEvent&gt; &lt;/PostBuildEvent&gt; &lt;/PropertyGroup&gt; &lt;!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. &lt;Target Name="BeforeBuild"&gt; &lt;/Target&gt; &lt;Target Name="AfterBuild"&gt; &lt;/Target&gt; --&gt; &lt;/Project&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload