Heroku部署.net控制台应用程序

时间:2020-05-03 04:24:54

标签: c# .net heroku

我正在尝试将控制台应用程序(.net core 3.1)部署到heroku。

我没有太多经验。我有一个buildpack,仅此而已。试图与该buildpack一起部署。

我遇到以下错误

C:\Users\SYDNEY\Desktop\twitchbot>git push heroku master
Enumerating objects: 546, done.
Counting objects: 100% (546/546), done.
Delta compression using up to 16 threads
Compressing objects: 100% (454/454), done.
Writing objects: 100% (546/546), 25.76 MiB | 658.00 KiB/s, done.
Total 546 (delta 159), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Core .NET app detected
remote: > Installing dotnet
remote: -----> Removing old cached .NET version
remote: -----> Fetching .NET SDK
remote: -----> Fetching .NET Runtime
remote: -----> Export dotnet to Path
remote: -----> Project File
remote: > /tmp/build_2de1ae7d9c84b2a5a6a6bd96b528c219/twitchbot.csproj
remote: -----> Project Name
remote: > twitchbot
remote: > publish /tmp/build_2de1ae7d9c84b2a5a6a6bd96b528c219/twitchbot.csproj for Release
remote:
remote: Welcome to .NET Core 3.1!
remote: ---------------------
remote: SDK Version: 3.1.201
remote:
remote: ----------------
remote: Explore documentation: https://aka.ms/dotnet-docs
remote: Report issues and find source on GitHub: https://github.com/dotnet/core
remote: Find out what's new: https://aka.ms/dotnet-whats-new
remote: Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
remote: Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
remote: Write your first app: https://aka.ms/first-net-core-app
remote: --------------------------------------------------------------------------------------
remote: Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
remote: Copyright (C) Microsoft Corporation. All rights reserved.
remote:
remote:   Restore completed in 5.22 sec for /tmp/build_2de1ae7d9c84b2a5a6a6bd96b528c219/twitchbot.csproj.
remote: obj/Release/netcoreapp3.1/linux-x64/twitchbot.AssemblyInfo.cs(13,12): error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute [/tmp/build_2de1ae7d9c84b2a5a6a6bd96b528c219/twitchbot.csproj]
remote: obj/Release/netcoreapp3.1/linux-x64/twitchbot.AssemblyInfo.cs(14,12): error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute [/tmp/build_2de1ae7d9c84b2a5a6a6bd96b528c219/twitchbot.csproj]
remote: obj/Release/netcoreapp3.1/linux-x64/twitchbot.AssemblyInfo.cs(15,12): error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute [/tmp/build_2de1ae7d9c84b2a5a6a6bd96b528c219/twitchbot.csproj]
remote: obj/Release/netcoreapp3.1/linux-x64/twitchbot.AssemblyInfo.cs(17,12): error CS0579: Duplicate 'System.Reflection.AssemblyProductAttribute' attribute [/tmp/build_2de1ae7d9c84b2a5a6a6bd96b528c219/twitchbot.csproj]
remote: obj/Release/netcoreapp3.1/linux-x64/twitchbot.AssemblyInfo.cs(18,12): error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute [/tmp/build_2de1ae7d9c84b2a5a6a6bd96b528c219/twitchbot.csproj]
remote: obj/Release/netcoreapp3.1/linux-x64/twitchbot.AssemblyInfo.cs(19,12): error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute [/tmp/build_2de1ae7d9c84b2a5a6a6bd96b528c219/twitchbot.csproj]
remote:  !     Push rejected, failed to compile Core .NET app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to csydneybot.
remote:
To https://git.heroku.com/csydneybot.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/csydneybot.git'

以下是我的根文件: enter image description here 有人知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

如果您已经拥有Assemblyinfo.cs,则可以删除该文件并在.csproj文件中添加以下内容

<PropertyGroup>
    <Company>Name</Company>
    <Authors>Author</Authors>
    <Version>1.0.0</Version>
    <AssemblyVersion>1.0.0.0</AssemblyVersion>
    <FileVersion>1.0.0.0</FileVersion>
</PropertyGroup>

  <PropertyGroup>
    <GenerateAssemblyInfo>true</GenerateAssemblyInfo>
  </PropertyGroup>

否则,如果需要保留assemblyinfo.cs,则必须将以下内容添加到.csproj中,以避免重新生成将被复制的assemblyinfo属性

  <PropertyGroup>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>

可以通过运行以下命令进行测试:dotnet build命令