【问题标题】:Error while trying to publish Azure Functions (v1) with VisualStudio 15.7.0 Preview 6.0尝试使用 VisualStudio 15.7.0 Preview 6.0 发布 Azure Functions (v1) 时出错
【发布时间】:2018-05-04 14:26:39
【问题描述】:

升级到 VisualStudio 15.7.0 预览版 6.0 后,我无法发布我的 Azure Functions (v1) 项目单击“发布”按钮时出现此错误

C:\程序 Files\dotnet\sdk\2.1.200-preview-007597\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(167,5):错误 : 资产文件'C:\Users\tonyv\source\repos\SistemaMulti\WebAPI\obj\project.assets.json' 没有“.NETFramework,Version=v4.6.1/win”的目标。确保您已为 TargetFrameworks 'net461' 恢复此项目 也许您还需要在您的项目的 RuntimeIdentifiers 中包含“win”。 [C:\Users\tonyv\source\repos\SistemaMulti\WebAPI\WebAPI.csproj]

我的 .csproj 是:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <Compile Remove="MercadoPago\Pessoa.cs" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.13" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="Microsoft.CSharp" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
  <ItemGroup>
    <Folder Include="MercadoPago\" />
  </ItemGroup>
</Project>

如何解决这个问题?

【问题讨论】:

  • 您能否检查一下 pubxml 中是否有以下条目(在 Properties\Publish Profiles\.pubxml 下)win。如果是这样,请删除此条目并重新尝试发布。
  • 我做了这些步骤,它有&lt;RuntimeIdentifier&gt;win&lt;/RuntimeIdentifier&gt;,然后我删除了它,发布了,我可以确认它现在可以正常工作了!将此作为答案,以便我可以标记接受

标签: visual-studio azure-functions


【解决方案1】:

问题是在发布配置文件中设置了以下属性(在Properties\Publish Profiles\&lt;profilename&gt;.pubxml 下)

<RuntimeIdentifier>win</RuntimeIdentifier>

从发布配置文件中删除此属性应该可以解决问题。

【讨论】:

    【解决方案2】:

    同样的问题有一个 github 线程 - https://github.com/Azure/Azure-Functions/issues/571

    推荐的解决方法是: 在 Properties\PublishProfiles\.pubxml 中更新这一行(删除 Any CPU 中的空间)。 &lt;LastUsedPlatform&gt;AnyCPU&lt;/LastUsedPlatform&gt;

    (从个人资料设置界面更新个人资料可能会重新添加空间。请在任何个人资料修改后将其删除)。

    【讨论】:

    • 您在上面提到的问题 (github.com/Azure/Azure-Functions/issues/571) 是一个不同的问题,它已在 VS 15.6 及更高版本中得到修复。我在上面添加了一个可能的解决方法的评论。我们正在调查根本原因。谢谢!
    猜你喜欢
    • 2021-08-12
    • 2022-01-02
    • 2019-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多