![](/img/trans.png)
[英]Error CS0234: The type or namespace name 'CustomMarshalers' does not exist in the namespace 'System.Runtime.InteropServices'
[英]Error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' VSTS (DevOps)
请纠正我的错误,尽管我已将路径设置为动态路径,但我在构建管道事件中不断出现上述错误,如下所示:
<PropertyGroup>
<!-- EnlistmentRoot is the base directory where all of the module root directories reside. -->
<EnlistmentRoot>$(MSBuildThisFileDirectory)</EnlistmentRoot>
<EnlistmentRoot Condition="'$(EnlistmentRoot)' != ''">$([System.IO.Path]::GetFullPath('$(EnlistmentRoot)'))</EnlistmentRoot>
<EnlistmentRoot Condition="'$(EnlistmentRoot)' != '' and !HasTrailingSlash('$(EnlistmentRoot)')">$(EnlistmentRoot)\</EnlistmentRoot>
</PropertyGroup>
<PropertyGroup>
<!-- NuGetPackagesPath is the base directory for all nuget packages. -->
<NuGetPackagesPath>$(EnlistmentRoot)..\packages</NuGetPackagesPath>
<NuGetPackagesPath Condition="'$(NuGetPackagesPath)' != ''">$([System.IO.Path]::GetFullPath('$(NuGetPackagesPath)'))</NuGetPackagesPath>
<NuGetPackagesPath Condition="'$(NuGetPackagesPath)' != '' and !HasTrailingSlash('$(NuGetPackagesPath)')">$(NuGetPackagesPath)\</NuGetPackagesPath>
</PropertyGroup>
<Reference Include="EntityFramework">
<HintPath>$(NugetPackagesPath)\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer">
<HintPath>$(NugetPackagesPath)\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServerCompact">
<HintPath>$(NugetPackagesPath)\EntityFramework.SqlServerCompact.6.1.3\lib\net45\EntityFramework.SqlServerCompact.dll</HintPath>
</Reference>
错误 CS0234:命名空间“System.Data”中不存在类型或命名空间名称“实体”
此错误消息表明构建过程无法找到来自还原的 nuget 包的程序集。 所以你应该在 build-pipeline 中检查restore task
的日志,以确保包恢复成功。
1.确保在像这样的build
任务之前use nuget
和nuget restore
任务(避免使用与 dotnet 相关的任务导致您的项目目标.net framework
):
2.如果在nuget restore
任务成功时问题仍然存在,请检查nuget restore
任务的日志以找到存储包的位置:
然后检查build
任务的日志以了解 msbuild 如何识别$(NugetPackagesPath)\\EntityFramework.6.1.3...
类的路径:
我们应该确保包被恢复的路径(restore task)和msbuild(build task)用来获取程序集的路径是一样的! 为此,您可能会从此问题中获得一些帮助。
另外:不确定为什么使用自定义的$(NugetPackagesPath)
而不是正常的
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
</Reference>
对于#2,您还可以将<hintpath>
的格式更改为正常方式以检查问题是否已解决。
希望它有所帮助,如果我误解了什么,请随时纠正我:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.