Discussion:
How to pull up a link to Microsoft.Csharp
(too old to reply)
o***@gmail.com
2020-07-20 10:06:43 UTC
Permalink
I need to pull up a link to Microsoft.Csharp if version .NET 4.0 or more. I wrote this import file: <?xml version="1.0" encoding="utf-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <DotNetVer>4.6</DotNetVer> <TargetFrameworkVersion>v$(DotNetVer)</TargetFrameworkVersion> </PropertyGroup> <ItemGroup Condition="$([System.Version]::Parse('$(DotNetVer)').CompareTo($([System.Version]::Parse('4.0')))) &gt;= 0">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>

But link on Microsoft.CSharp appear also for .NET 3.5 и 4.6
Why is this happening?
Anton Shepelev
2020-07-22 17:33:45 UTC
Permalink
I need to pull up a link to Microsoft.Csharp if version
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>
But link on Microsoft.CSharp appear also for .NET 3.5 и
4.6 Why is this happening?
I believe a complete .csproj would be more useful, e.g.: <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration>Debug</Configuration> <Platform>AnyCPU</Platform> <PlatformTarget>AnyCPU</PlatformTarget> <ProjectGuid>{1E70CA1B-6696-4A5A-AF4F-35B1BEBE19A4}</ProjectGuid> <OutputType>Exe</OutputType> <RootNamespace>doptnetver</RootNamespace> <AssemblyName>doptnetver</AssemblyName> <OutputPath>bin\</OutputPath> <DotNetVer>3.5</DotNetVer> <TargetFrameworkVersion>v$(DotNetVer)</TargetFrameworkVersion> </PropertyGroup> <ItemGroup Condition="$([System.Version]::Parse('$(DotNetVer)').CompareTo($([System.Version]::Parse('4.0')))) &gt;= 0">
<Reference Include="Microsoft.CSharp"/>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

For the sake of the test, I replaced Microsoft.CSharp with
System.Xml and declared an XmlDocument in the Main()
function, and alghough Studio 2015 still displays the
reference to System.Xml with .NET 3.5, it is shows it with
an exclamation point and the project does not complie
because -- guess what? -- System.Xml is missing! I therefore
think it is this display bug in Visual Studio that misled
you into thinking your import file defective. It works :-)
--
() ascii ribbon campaign - against html e-mail
/\ http://preview.tinyurl.com/qcy6mjc [archived]
Loading...