【发布时间】:2017-12-19 13:54:36
【问题描述】:
我们尝试使用 .NET Framework 4.6.1 构建 .NET Standard Library 1.4 项目,在 windows server 2012 RC2 中使用没有 Visual Studio 的命令提示符用于自动化目的。
我已经在服务器上安装了以下内容,
.Net Framework 4.6.1
.Net Framework 4.6.1 Targeting pack
Microsoft Build Tools 2015
这个 .NET 标准库项目说 ProjectA 被其他两个 .NET 标准库项目 ProjectB 和 ProjectC 引用。
将 ProjectA 保留为启动项目
当我尝试在 dotnet restore 之后使用 dotnet build cmd 编译 ProjectA 时,我收到以下错误,
C:\Document\ProjectA>dotnet build
Project ProjectA (.NETStandard,Version=v1.4) will be compiled because
expected outputs are missing
Compiling ProjectA for .NETStandard,Version=v1.4
C:\Program Files\dotnet\dotnet.exe compile-csc
@C:\Document\ProjectA\obj\Debug\netstandard1.4\dotnet-compile.rsp returned
Exit Code 1
C:\Document\ProjectA\Sample.cs(1,17): error CS0234: The type or namespace name
'ProjectB' does not exist in the namespace 'XYZ' (are you missing an
assembly reference?)
C:\Document\ProjectA\Sample.cs(2,17): error CS0234: The type or namespace name
'ProjectC' does not exist in the namespace 'XYZ' (are you missing an
assembly reference?)
Compilation failed.
0 Warning(s)
2 Error(s)
请帮助我从命令提示符编译解决方案。 示例代码:
using XYZ.ProjectB;
using XYZ.ProjectC;
using System;
namespace XYZ.ProjectA
{
public class Sample : ISample
{
public Void GetMessage()
{
var s=XYZ.ProjectB.GetList();
Console.Write("");
}
}
}
ProjectB 和 Project C 也是 .Netstandard Lib
【问题讨论】:
-
The type or namespace name 'ProjectB' does not exist in the namespace 'XYZ'这说明了一切!,这些项目没有相同的根命名空间! -
感谢您的回复 Suraj。它存在于同一个命名空间中..它在Visual Studio中正确编译和执行..但是当我在命令提示符的帮助下编译时会抛出错误。
-
您需要在
ABC.cs提供代码 -
包含在问题中
-
您仍在使用 project.json 的任何原因?我强烈建议您更新到最终的 1.0 工具。它会让一切大大变得更简单。
标签: c# windows command-line msbuild .net-4.6.1