msbuild VS2017 解决方案,其中包含 netstandard 库
msbuild VS2017 solution with netstandard library in it
我创建了一个 VS2017 解决方案,其中包含一个针对 .NETStandard 1.4 的示例库
为此我添加了一个 class:
using System;
namespace ExampleNetstandard
{
public class Example
{
public string A { get; set; }
}
}
从 visual studio 编译正常,但如果您清除 bin 和 obj 目录,然后使用以下命令从 msbuild 构建:msbuild ExampleNetstandard.sln /t:Build /p:Configuration=Release /p:平台="Any CPU"
我收到以下错误:
C:\Users\Aaron\AppData\Local\Temp.NETStandard,Version=v1.4.AssemblyAttributes.cs(4,20):
error CS0400: The type or name space name 'System' could not be found
in the global namespace (are you missing an assembly reference?)
[D:\src\Example Netstandard\ExampleNetstandard.csproj]
obj\Release\netstandard1.4\ExampleNetstandard.AssemblyInfo.cs(6,12):
error CS0246: The type or namespace name 'System' could not be found
(are you missing a using directive or an assembly reference?)
[D:\src\ExampleNetstandard\ExampleNets tandard.csproj]
我需要做些什么才能从 msbuild 构建此类项目?我正在调查这个问题,因为我们的 TeamCity 服务器在实际项目中抛出了这个错误
如果您炸毁了您的 bin 和 obj 目录,您将需要再次恢复您的包。当你 运行 dotnet restore
有一些文件在你的 obj 目录中发出,你需要编译。此外,对于 dotnet 核心项目,您应该坚持使用 dotnet cli。由于 dotnet cli 附带了适用于核心的正确版本的 msbuild。
您可以通过 运行ning dotnet restore
恢复您的包,然后 运行 dotnet build -c Release
编译您的应用程序。任何时候清理 obj 目录都必须 运行 dotnet restore
我创建了一个 VS2017 解决方案,其中包含一个针对 .NETStandard 1.4 的示例库
为此我添加了一个 class:
using System;
namespace ExampleNetstandard
{
public class Example
{
public string A { get; set; }
}
}
从 visual studio 编译正常,但如果您清除 bin 和 obj 目录,然后使用以下命令从 msbuild 构建:msbuild ExampleNetstandard.sln /t:Build /p:Configuration=Release /p:平台="Any CPU"
我收到以下错误:
C:\Users\Aaron\AppData\Local\Temp.NETStandard,Version=v1.4.AssemblyAttributes.cs(4,20): error CS0400: The type or name space name 'System' could not be found in the global namespace (are you missing an assembly reference?) [D:\src\Example Netstandard\ExampleNetstandard.csproj] obj\Release\netstandard1.4\ExampleNetstandard.AssemblyInfo.cs(6,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [D:\src\ExampleNetstandard\ExampleNets tandard.csproj]
我需要做些什么才能从 msbuild 构建此类项目?我正在调查这个问题,因为我们的 TeamCity 服务器在实际项目中抛出了这个错误
如果您炸毁了您的 bin 和 obj 目录,您将需要再次恢复您的包。当你 运行 dotnet restore
有一些文件在你的 obj 目录中发出,你需要编译。此外,对于 dotnet 核心项目,您应该坚持使用 dotnet cli。由于 dotnet cli 附带了适用于核心的正确版本的 msbuild。
您可以通过 运行ning dotnet restore
恢复您的包,然后 运行 dotnet build -c Release
编译您的应用程序。任何时候清理 obj 目录都必须 运行 dotnet restore