我有一个包含3个类库项目(业务逻辑,数据访问层,Web服务)的解决方案。
我可以在Visual Studio中构建解决方案。
但是,当构建任务在Azure DevOps中运行时,它会失败,并会出现以下错误:命名空间或类型不存在。错误是由于其中一个类库项目依赖于另一个。
这里可能是什么问题?
第二部分是,当我为Web应用程序添加构建任务时,如何确保Web应用程序可以从类库项目解决方案的第一次构建中正确引用DLLS(以便自行构建)正确)?
以下是解决方案文件的摘录-“未找到”错误与 MatterDBLibrary 项目有关。
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MatterDBBusinessEntities", "MatterDBBusinessEntities\MatterDBBusinessEntities.csproj", "{EC049257-C855-47DC-A2DF-02910DBC34A3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MattersDBService", "MattersDBService\MattersDBService.csproj", "{34F4FE24-948B-4EF2-8252-7FDA8430616F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MatterDBLibrary",
"MatterDBLibrary\MatterDBLibrary.csproj", "{D76D1BFC-8B1E-4A3F-AC76-3218CA28E5D7}"
ProjectSection(ProjectDependencies) = postProject
{34F4FE24-948B-4EF2-8252-7FDA8430616F} = {34F4FE24-948B-4EF2-8252-7FDA8430616F}
{EC049257-C855-47DC-A2DF-02910DBC34A3} = {EC049257-C855-47DC-A2DF-02910DBC34A3}
EndProjectSection
EndProject
MatterDB参考:
<ProjectReference Include="..\MatterDBBusinessEntities\MatterDBBusinessEntities.csproj">
<Project>{ec049257-c855-47dc-a2df-02910dbc34a3}</Project>
<Name>MatterDBBusinessEntities</Name>
</ProjectReference>
MatterDBService参考:
<ProjectReference Include="..\MatterDBBusinessEntities\MatterDBBusinessEntities.csproj">
<Project>{ec049257-c855-47dc-a2df-02910dbc34a3}</Project>
<Name>MatterDBBusinessEntities</Name>
</ProjectReference>
第三个项目(MatterDBBusinessEntities)与以上两个项目无关。
##[warning]MattersDB\DEV\MatterDBLibrary\Fakes\MatterDBBusinessEntities.fakes(0,0): Warning : Some fakes could not be generated. For complete details, set Diagnostic attribute of the Fakes element in this file to 'true' and rebuild the project.
2019-06-24T17:37:09.1641534Z D:\a\1\s\MattersDB\DEV\MatterDBLibrary\Fakes\MatterDBBusinessEntities.fakes : warning : Some fakes could not be generated. For complete details, set Diagnostic attribute of the Fakes element in this file to 'true' and rebuild the project. [D:\a\1\s\MattersDB\DEV\MatterDBLibrary\MatterDBLibrary.csproj]
2019-06-24T17:37:09.2160099Z ResolveAssemblyReferences:
2019-06-24T17:37:09.2160196Z Primary reference "MatterDBBusinessEntities".
2019-06-24T17:37:09.2161791Z ##[warning]C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): Warning MSB3245: Could not resolve this reference. Could not locate the assembly "MatterDBBusinessEntities". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
2019-06-24T17:37:09.2163119Z C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "MatterDBBusinessEntities". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\a\1\s\MattersDB\DEV\MatterDBLibrary\MatterDBLibrary.csproj]
2019-06-24T17:37:09.2163318Z For SearchPath "{HintPathFromItem}".
2019-06-24T17:37:09.2163467Z Considered "..\MatterDBBusinessEntities\bin\Debug\MatterDBBusinessEntities.dll", but it didn't exist.
2019-06-24T17:37:09.2163632Z For SearchPath "{TargetFrameworkDirectory}".
2019-06-24T17:37:09.4347164Z C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe /noconfig /unsafe+ /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE /highentropyva+ /reference:D:\a\1\s\MattersDB\DEV\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll /reference:D:\a\1\s\MattersDB\DEV\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll /reference:"D:\a\1\s\Deals\Phase 3\DEV\ExternalReference\Korzh.EasyQuery.Db.NET45.dll" /reference:"D:\a\1\s\Deals\Phase 3\DEV\ExternalReference\Korzh.EasyQuery.Mvc.NET45.dll" /reference:"D:\a\1\s\Deals\Phase 3\DEV\ExternalReference\Korzh.EasyQuery.NET45.dll" /reference:"D:\a\1\s\Deals\Phase 3\DEV\ExternalReference\MatterDBLibrary.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies\Microsoft.QualityTools.Testing.Fakes.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\mscorlib.dll" /reference:"D:\a\1\s\MattersDB\DEV\External References\Newtonsoft.Json.dll" /reference:"D:\a\1\s\Deals\Phase 3\DEV\ExternalReference\Stikeman.Extension.Object.dll" /reference:"D:\a\1\s\Deals\Phase 3\DEV\ExternalReference\Stikeman.Extension.String.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.ComponentModel.DataAnnotations.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Configuration.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.EnterpriseServices.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Net.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Net.Http.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Runtime.Caching.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Runtime.Serialization.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Security.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.ServiceModel.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Web.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Web.Services.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Xml.Linq.dll" /debug:pdbonly /filealign:512 /optimize- /out:obj\Release\MatterDBLibrary.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /subsystemversion:6.00 /resource:obj\Release\Stikeman.MatterDB.Library.Properties.Resources.resources /target:library /utf8output Constant.cs DataModel\EntityAttributes.cs DataModel\Enum.cs DataModel\Operators.cs DataModel\SavedSearchModel.cs DataModel\SearchModel.cs DataModel\SearchQueryModel.cs ImpersonateManager.cs MatterDBBuilder.cs MatterDBController.cs MatterDBPersistor.cs MatterLockException.cs Properties\AssemblyInfo.cs Properties\Resources.Designer.cs Properties\Settings.Designer.cs DataModel\SearchResultModel.cs "Service References\ContactServices\Reference.cs" "Service References\EmployeeServices\Reference.cs" "Service References\EthicalWallServices\Reference.cs" UserNotFoundException.cs Utils.cs "Web References\IntAppServices\Reference.cs" "C:\Users\VssAdministrator\AppData\Local\Temp\.NETFramework,Version=v4.6.AssemblyAttributes.cs"
2019-06-24T17:37:09.4348317Z Using shared compilation with compiler from directory: C:\Program Files (x86)\MSBuild\14.0\bin
2019-06-24T17:37:10.0330700Z ##[warning]MattersDB\DEV\MatterDBLibrary\ImpersonateManager.cs(7,40): Warning CS0618: 'SecurityAction.RequestMinimum' is obsolete: 'Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.'
2019-06-24T17:37:10.0331697Z ImpersonateManager.cs(7,40): warning CS0618: 'SecurityAction.RequestMinimum' is obsolete: 'Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.' [D:\a\1\s\MattersDB\DEV\MatterDBLibrary\MatterDBLibrary.csproj]
2019-06-24T17:37:10.0332924Z ##[warning]MattersDB\DEV\MatterDBLibrary\ImpersonateManager.cs(8,35): Warning CS0618: 'SecurityAction.RequestMinimum' is obsolete: 'Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.'
2019-06-24T17:37:10.0333757Z ImpersonateManager.cs(8,35): warning CS0618: 'SecurityAction.RequestMinimum' is obsolete: 'Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.' [D:\a\1\s\MattersDB\DEV\MatterDBLibrary\MatterDBLibrary.csproj]
MattersDB\DEV\MatterDBLibrary\DataModel\SearchQueryModel.cs(1,25): Error CS0234: The type or namespace name 'BusinessEntities' does not exist in the namespace 'Stikeman.MatterDB' (are you missing an assembly reference?)
MattersDB\DEV\MatterDBLibrary\MatterDBBuilder.cs(14,25): Error CS0234: The type or namespace name 'BusinessEntities' does not exist in the namespace 'Stikeman.MatterDB' (are you missing an assembly reference?)
MattersDB\DEV\MatterDBLibrary\MatterDBController.cs(18,31): Error CS0234: The type or namespace name 'BusinessEntities' does not exist in the namespace 'Stikeman.MatterDB' (are you missing an assembly reference?)
MattersDB\DEV\MatterDBLibrary\MatterDBController.cs(17,25): Error CS0234: The type or namespace name 'BusinessEntities' does not exist in the namespace 'Stikeman.MatterDB' (are you missing an assembly reference?)
MattersDB\DEV\MatterDBLibrary\MatterDBPersistor.cs(9,25): Error CS0234: The type or namespace name 'BusinessEntities' does not exist in the namespace 'Stikeman.MatterDB' (are you missing an assembly reference?)
MattersDB\DEV\MatterDBLibrary\MatterDBPersistor.cs(10,25): Error CS0234: The type or namespace name 'BusinessEntities' does not exist in the namespace 'Stikeman.MatterDB' (are you missing an assembly reference?)
MattersDB\DEV\MatterDBLibrary\DataModel\SearchResultModel.cs(1,25): Error CS0234: The type or namespace name 'BusinessEntities' does not exist in the namespace 'Stikeman.MatterDB' (are you missing an assembly reference?)
MattersDB\DEV\MatterDBLibrary\DataModel\SearchResultModel.cs(37,16): Error CS0246: The type or namespace name 'NamedObject' could not be found (are you missing a using directive or an assembly reference?)
MattersDB\DEV\MatterDBLibrary\DataModel\SearchQueryModel.cs(41,21): Error CS0246: The type or namespace name 'NamedObject' could not be found (are you missing a using directive or an assembly reference?)
MattersDB\DEV\MatterDBLibrary\DataModel\SearchQueryModel.cs(152,16): Error CS0246: The type or namespace name 'NamedObject' could not be found (are you missing a using directive or an assembly reference?)
提前谢谢。
答案 0 :(得分:1)
但是,当构建任务在Azure DevOps中运行时,它会失败,并会出现以下错误:命名空间或类型不存在。错误是由于其中一个类库项目依赖于另一个。
由于一个类库项目依赖于另一个,因此,要解决此问题,最好的解决方案是为类库项目添加项目引用。然后在构建任务上,在“解决方案”选项中选择解决方案文件.sln
文件:
然后,MSBuild / Visual Studio将首先基于项目文件中的引用关系选择构建引用的项目,例如<ProjectReference Include="..\TestReferenceApp\TestReferenceApp.csproj">
,然后将输出复制到引用项目的目录中。
第二部分是,当我为Web添加构建任务时 应用程序,如何确保Web应用程序可以引用 从类库项目的第一个生成正确地DLLS 解决方案(以便正确构建自己)?
就像第一个问题的答案一样,将项目引用添加到Web应用程序。如果添加引用仅限于您,则可以先构建类库项目,然后添加copy task将库复制到Web应用程序的输出。或者,您可以将类库项目打包为nuget软件包,然后将此nuget软件包添加到Web应用程序中。
希望这会有所帮助。