无法在 Visual Studio 中构建调试版本的 Azure Function

Can't build debug version Azure Function in Visual Studio

我是第一次尝试 Azure Functions,并且能够毫无问题地构建和发布 "Release" 个版本。

我想单步执行代码,因此需要创建和发布一个 "Debug" 版本,但是当我尝试构建时,使用相同的代码出现以下错误:

CS0579  Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute
CS0579  Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute
CS0579  Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute
CS0579  Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute
CS0579  Duplicate 'System.Reflection.AssemblyProductAttribute' attribute
CS0579  Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute
CS0579  Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute

通过研究这个错误,主要建议是将它们从 AssemblyInfo.cs 文件中删除,但重建只是将它们重新放回原处,"Release" 版本对这些设置感到满意。

我缺少什么,所以我可以创建代码的 "Debug" 版本?

谢谢

根据您对CS0579 Duplicate error ,I suppose some temporary *.cs files generated during compilation got accidentally added to the project. The files were from the obj\Debug directory, you could try to delete these files to solve problem. For more details, you could refer to this SO thread的描述。

In my case, some temporary *.cs files generated during compilation got accidentally added to the project.

The files were from the obj\Debug directory, so they definitely shouldn't have been added to the solution. A *.cs wildcard went a little crazy and added them incorrectly.

如果还是不行,您也可以尝试其他解决方案。例如 右键单击​​项目名称 > 选择 编辑 FunctionName.csproj. 编辑 csproj 并关闭导致问题的属性的生成。更多解决方案可以参考这个article.

Resolution

I found this issue on GitHub where there were a couple of options to resolve this issue which I am going to cover here plus a third option I tried not mention in the issue.

我现在已经按照 Janley 的 link 之一并在 .csproj 文件中添加 4 行额外的行来构建调试:

<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>