Reputation: 39768
I am trying to compile some C# code with .NET Core. My last attempt was hindered by YamlDotNet not supporting .NET Core, but that has changed.
So, I set up a project like this:
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\YamlDotNet\YamlDotNet\YamlDotNet.csproj" />
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
</PropertyGroup>
</Project>
I ran:
dotnet restore
That was successful. Then I tried:
dotnet build
This yielded the following error:
/usr/share/dotnet/sdk/1.0.1/Microsoft.Common.CurrentVersion.targets(1111,5):
error MSB3644: The reference assemblies for framework ".NETCoreApp,Version=v1.0"
were not found. To resolve this, install the SDK or Targeting Pack for this
framework version or retarget your application to a version of the framework for
which you have the SDK or Targeting Pack installed. Note that assemblies will be
resolved from the Global Assembly Cache (GAC) and will be used in place of
reference assemblies. Therefore your assembly may not be correctly targeted for
the framework you intend.
[/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
/usr/share/dotnet/sdk/1.0.1/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.targets(92,5):
error : Cannot find project info for '/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj'.
This can indicate a missing project reference.
[/work/yaml-editor/docker/src/dotnet/dotnet.csproj]
I am using the official microsoft/dotnet:1.0-sdk
docker container, so I don't understand why .NETCoreApp,Version=v1.0
is missing. How can I fix the error?
Update:
I figured out that I have to configure <TargetFramework>netstandard1.3</TargetFramework>
which is also present in YamlDotNet.csproj
. However, now I get this error:
/usr/share/dotnet/sdk/1.0.1/Microsoft.CSharp.CurrentVersion.targets(133,9): warning MSB3884: Could not find rule set file "MinimumRecommendedRules.ruleset". [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Core/YamlException.cs(113,30): error CS0115: 'YamlException.GetObjectData(SerializationInfo, StreamingContext)': no suitable method found to override [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Core/YamlException.cs(112,26): error CS0234: The type or namespace name 'Permissions' does not exist in the namespace 'System.Security' (are you missing an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Core/YamlException.cs(112,57): error CS0234: The type or namespace name 'Permissions' does not exist in the namespace 'System.Security' (are you missing an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Core/YamlException.cs(112,112): error CS0246: The type or namespace name 'Flags' could not be found (are you missing a using directive or an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Core/YamlException.cs(112,120): error CS0234: The type or namespace name 'Permissions' does not exist in the namespace 'System.Security' (are you missing an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Serialization/Utilities/TypeConverter.cs(45,26): error CS0234: The type or namespace name 'Permissions' does not exist in the namespace 'System.Security' (are you missing an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Serialization/Utilities/TypeConverter.cs(45,52): error CS0234: The type or namespace name 'Permissions' does not exist in the namespace 'System.Security' (are you missing an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Serialization/Utilities/TypeConverter.cs(45,107): error CS0246: The type or namespace name 'Name' could not be found (are you missing a using directive or an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Serialization/Utilities/TypeConverter.cs(47,54): error CS0234: The type or namespace name 'TypeConverter' does not exist in the namespace 'System.ComponentModel' (are you missing an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
/usr/share/dotnet/sdk/1.0.1/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.targets(92,5): error : Cannot find project info for '/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj'. This can indicate a missing project reference. [/work/yaml-editor/docker/src/dotnet/dotnet.csproj]
make: *** [build/bin/dotnet-event] Error 1
I remember to have seen similar errors when I last tried this, but I wonder why it still happens, since YamlDotNet claims to support .NET Core.
Upvotes: 3
Views: 965
Reputation: 11
I had the same error, which I resolved by adding:
using YamlDotNet.RepresentationModel;
Try adding one of the four namespaces and see which works:
using YamlDotNet.Serialization
using YamlDotNet.RepresentationModel
using YamlDotNet.Helpers
using YamlDotNet.Core
Upvotes: 1