msbuild 在 projects.assets.json 中找不到引用
msbuild can't find references in projects.assets.json
我有一个针对 .net 标准 2.0 的 .net 标准库项目,我正在尝试使用 MSBuild 在 VSTS 中构建它,安装构建代理的构建服务器没有互联网访问权限,所以我复制了依赖于 C:\users\username.nuget\packages 文件夹,但是 MSBuild 无法显示“Netsdk1064,包 microsoft.csharp,未找到版本 4.3.0”。
我已经尝试复制解决方案的 packages 文件夹上的依赖项,但现在仍在工作。我无法在构建服务器上使用 Nuget 还原,所以我想知道是否有办法重定向 project.assets.json 以查看我创建的文件夹?
您需要检查包 Netsdk1064, Package microsoft.csharp
是否已成功复制到 C:\users\username\.nuget\packages folder
,因为它出错,找不到此包。
作为解决方法,您可以创建一个 nuget.config 文件并提交到您的存储库。并在 nuget.config 文件的 packageSources
元素下添加所有包所在的本地目录。请参阅下面的示例。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="local" value="C:\users\username\.nuget\packages" />
</packageSources>
</configuration>
查看 nuget.config 的 Package source sections 了解更多信息。
然后就可以使用nuget restore task来恢复包了。并设置 nugetConfigPath
指向上面创建的 nuget.config。
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: 'SmartFuel.sln'
feedsToUse: 'config'
nugetConfigPath: 'nuget.config'
如果 nuget 恢复任务无法从本地包源恢复。请检查管道中使用的 nuget 版本。如果 nuget 版本为 4.1.0 或更早版本。您需要使用 NuGet Tool Installer task to use a higher versions of nuget. See this thread 获取更多信息。
另一种可能的解决方法是编辑 .csproj 文件并使用 hintpath
手动将引用的包指向本地文件夹中的 .dll。例如下面:
<ItemGroup>
<Reference Include="DependPackage">
<HintPath>..\..\..\..\..\..\package\DependPackage.dll</HintPath>
</Reference>
</ItemGroup>
我有一个针对 .net 标准 2.0 的 .net 标准库项目,我正在尝试使用 MSBuild 在 VSTS 中构建它,安装构建代理的构建服务器没有互联网访问权限,所以我复制了依赖于 C:\users\username.nuget\packages 文件夹,但是 MSBuild 无法显示“Netsdk1064,包 microsoft.csharp,未找到版本 4.3.0”。 我已经尝试复制解决方案的 packages 文件夹上的依赖项,但现在仍在工作。我无法在构建服务器上使用 Nuget 还原,所以我想知道是否有办法重定向 project.assets.json 以查看我创建的文件夹?
您需要检查包 Netsdk1064, Package microsoft.csharp
是否已成功复制到 C:\users\username\.nuget\packages folder
,因为它出错,找不到此包。
作为解决方法,您可以创建一个 nuget.config 文件并提交到您的存储库。并在 nuget.config 文件的 packageSources
元素下添加所有包所在的本地目录。请参阅下面的示例。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="local" value="C:\users\username\.nuget\packages" />
</packageSources>
</configuration>
查看 nuget.config 的 Package source sections 了解更多信息。
然后就可以使用nuget restore task来恢复包了。并设置 nugetConfigPath
指向上面创建的 nuget.config。
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: 'SmartFuel.sln'
feedsToUse: 'config'
nugetConfigPath: 'nuget.config'
如果 nuget 恢复任务无法从本地包源恢复。请检查管道中使用的 nuget 版本。如果 nuget 版本为 4.1.0 或更早版本。您需要使用 NuGet Tool Installer task to use a higher versions of nuget. See this thread 获取更多信息。
另一种可能的解决方法是编辑 .csproj 文件并使用 hintpath
手动将引用的包指向本地文件夹中的 .dll。例如下面:
<ItemGroup>
<Reference Include="DependPackage">
<HintPath>..\..\..\..\..\..\package\DependPackage.dll</HintPath>
</Reference>
</ItemGroup>