Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to pull up a link to Microsoft.Csharp

12 views
Skip to first unread message

o.kis...@gmail.com

unread,
Jul 20, 2020, 6:06:49 AM7/20/20
to
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

unread,
Jul 22, 2020, 1:33:53 PM7/22/20
to
o.kislov213:
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]
0 new messages