重现步骤
在 VS2017 中创建net461
引用相同 4.6.1 的 ClassLibrary 的核心 webproject。在库中定义
public class X
{
[Required] // using System.ComponentModel.DataAnnotations;
public bool Q { get; set; }
}
在 webapp 中使用它:new ClassLibrary1.X();
在 VS 中构建,在 cmd 中通过 msbuild 构建,OK。
运行dotnet restore
,dotnet build
你会得到
Class1.cs(5,14): error CS0234: The type or namespace name 'Net' does not exist in the namespace 'System' (are you missing an assembly reference?) [C:\Users\xxx\Documents\Visual Studio 2017\Projects\coretest\ClassLibrary1\ClassLibrary1.csproj]
C:\Program Files\dotnet\sdk\1.0.0\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(92,5): error : Cannot find project info for 'C:\Users\xxx\Documents\Visual Studio 2017\Projects\coretest\ClassLibrary1\ClassLibrary1.csproj'. This can indicate a missing project reference. [C:\Users\xxx\Documents\Visual Studio 2017\Projects\coretest\WebApplication1\WebApplication1.csproj]
dotnet --info
输出:.NET 命令行工具 (1.0.0)
产品信息: 版本:1.0.0 提交 SHA-1 哈希:e53429feb4
运行环境:操作系统名称:Windows 操作系统版本:10.0.14393 操作系统平台:Windows RID:win10-x64 基本路径:C:\Program Files\dotnet\sdk\1.0.0