首页 > 解决方案 > 新 Azure Functions 项目中的“System.Reflection.AssemblyCompanyAttribute”属性重复

问题描述

当我想将我的新项目部署到 Azure 时,我收到许多错误消息。

装配信息.cs:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("Newfunctions")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Newfunctions")]
[assembly: System.Reflection.AssemblyTitleAttribute("Newfunctions")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

错误信息:

Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute [Newfunctions]
Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute [Newfunctions]
Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute [Newfunctions]
Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute [Newfunctions]
Duplicate 'System.Reflection.AssemblyProductAttribute' attribute [Newfunctions]
Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute [Newfunctions]
Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute [Newfunctions]

AssemblyAttributes.cs 中的另一个:

// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]

错误信息:

Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute [Newfunctions]

我在程序集类中没有添加或更改任何内容。我只在 Visual Studio Code 中安装了 Azure Functions 扩展和 PlayFab Explorer 扩展。此外,我已将 nuget 包 PlayFabAllSDK 和 PlayFabCloudScriptPlugin 添加到我的项目中。我不知道我做错了什么。

我的项目有什么问题?如何修复这些错误消息?

错误信息

新功能.csproj:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.7"/>
<PackageReference Include="PlayFabAllSDK" Version="1.81.200914"/>
<PackageReference Include="PlayFabCloudScriptPlugin" Version="1.53.190627-alpha"/>
</ItemGroup>
<ItemGroup>
<None Update="host.json">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  <CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>

标签: c#visual-studio-code

解决方案


添加<GenerateAssemblyInfo>false</GenerateAssemblyInfo>到项目文件对我不起作用。然而,起作用的是删除所有发生错误的项目中的binobj文件夹。然后重新启动 Visual Studio 并尝试再次运行。


推荐阅读