2017-07-03 77 views
0

我使用VS2017创建了一个Windows Runtime Component (Universal)类型的项目。项目文件包括包参考:如果启用该选项通过VS2017中的nuget恢复依赖关系

<ItemGroup> 
    <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform"> 
     <Version>5.2.3</Version> 
    </PackageReference> 
    </ItemGroup> 

一切正常:Automatically check for missing packages during build in Visual Studio

enter image description here

但我有一些情况下(这个选项被禁用,通过CLI建立,服务器CI构建)如果在编译期间没有自动恢复此依赖关系,生成后obj文件夹中缺少project.assets.json。它会导致很多像这样的错误:error CS0518: Predefined type 'System.String' is not defined or imported

是否可以通过项目文件(.csproj)自动恢复软件包引用?

感谢

回答

1

构建解决方案,以恢复所有的包,并确保您的CI使用的MSBuild 15.x.之前执行msbuild -t:restore your.sln

+0

感谢您的回应,但我也需要恢复兼容性,使用MSBuild版本低于15的VS2015。 – Bob

+1

@Bob告别VS 2015.没有回头路可走。 –

相关问题