我们最近从一个大的SLN文件转移到多个SLN文件 . 所以现在文件夹结构是这样的:
-
Root
-
Solution1WebApp
-
包(文件夹)
-
Project1(文件夹)
-
Project1.csproj
-
NuGet.config
-
Solution1.sln
-
Solution2Libraries
-
包(文件夹)
-
Project1(文件夹)
-
Project1.csproj
-
Project2(文件夹)
-
Project2.csproj
-
NuGet.config
-
Solution2.sln
-
Solution3UnitTests
-
包(文件夹)
-
Project1(文件夹)
-
Project1.csproj
-
Project2(文件夹)
-
Project2.csproj
-
Project3(文件夹)
-
Project3.csproj
-
NuGet.config
-
Solution3.sln
当我在Visual Studio Online中签入时,会触发构建 . 此构建配置为检索nuget包(因此未签入包文件夹) .
在Solution1的csproj文件中,我将指向包的所有路径配置为如下所示:
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\Solution1WebApp\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
但构建仍然失败,我得到这样的警告:
C:\Program Files (x86)\MSBuild\14.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1819, 5)
Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
我认为这些警告会导致以下异常:
The type or namespace name 'xxx' does not exist in the namespace 'yyy' (are you missing an assembly reference?)
我错过了什么吗?路径是否正确配置?
谢谢你的帮助 .
2 回答
好的,我找到了答案 . 包路径必须保持不带解决方案名称:
在VSO构建定义中,我为每个解决方案添加了构建步骤(库的一个步骤,单元测试的一个步骤和Web应用程序的一个步骤) .
这样,每个解决方案都在构建,并且路径可以与我们PC上的本地路径保持一致 .
删除在packages.json文件中提及的引用和项目 .
将它们添加回其找不到文件的解决方案中的项目 .
保存并提交..为我工作 .