qqq*_*qqq 11 .net-core visual-studio-code asp.net-core
我正在尝试深入研究 ASP.NET Core。因此,我决定尝试使用 VS Code 创建一个宠物项目。
在 dotnet cmd 的帮助下,我创建了一个解决方案,向其中添加了项目(应用程序、测试、EF、映射等)并在项目之间设置引用。
但现在,当我尝试运行该解决方案时,我收到了Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute错误和一堆其他奇怪的错误。这是我收到的错误的一部分:
c:\Projects\dotNet\BestTongue\Utilities\objBinRemove\obj\Debug\netcoreapp3.0\objBinRemove.AssemblyInfo.cs(10,12): error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute [C:\Projects\dotNet\BestTongue\BestTongue.csproj]
c:\Projects\dotNet\BestTongue\Utilities\objBinRemove\obj\Debug\netcoreapp3.0\objBinRemove.AssemblyInfo.cs(11,12): error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute [C:\Projects\dotNet\BestTongue\BestTongue.csproj]
...
Run Code Online (Sandbox Code Playgroud)
我不确定我还需要在问题中添加什么才能解决问题。因此,如果我遗漏了某些内容,请在评论中询问所有必要的详细信息。
我花了很多时间试图找到问题的解决方案,但徒劳无功。
更新
正如评论部分所建议的那样,我尝试使用相关问题中提到的解决方案。
我尝试添加:
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
所以,现在我的.csproj样子是这样的:
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\App\App.csproj" />
<ProjectReference Include="..\Data\Data.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>netstandard3.0</TargetFramework>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
</PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
但我仍然看到同样的错误:
另外,我编写了一个脚本来遍历所有项目并删除*.AssemblyInfo.cs. 之后我检查了建设项目是否会带回来*.AssemblyInfo.cs。并且*.AssemblyInfo.cs在构建后再次出现。另外,现在(.csproj文件修改后)我收到了一个新错误:
C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(140,5):错误 NETSDK1045:当前 .NET SDK 不支持定位 。 NET 标准 3.0。以 .NET Standard 2.1 或更低版本为目标,或者使用支持 .NET Standard 3.0 的 .NET SDK 版本。[C:\Projects\dotNet\BestTongue\Controllers\Controllers.csproj] C:\Program
Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(140,5):错误NETSDK1045:当前.NET SDK不支持定位.NET Standard 3.0。以 .NET Standard 2.1 或更低版本为目标,或者使用支持 .NET Standard 3.0 的 .NET SDK 版本。[C:\Projects\dotNet\BestTongue\App\App.csproj]
对于试图帮助我在本地检查解决方案的人来说可能很有用。这是包含最新更改的解决方案存储库。
Joh*_*ine 10
这是正确的(上面的 Ian Kemp nos 1)。我正在将 .net 应用程序升级到 .net core 5,付出了痛苦的努力来消除这个问题。现在一切都好。在您的 .net core 应用程序上进行文件搜索(我假设 3.X 是相同的)并删除所有 AssemblyInfo.cs 文件(.net core 从项目文件构建 AssembleyInfo 因此,如果您也删除这些文件也没关系。重新编译,问题就会消失。另外,请确保您的库(DLL)文件在属性组中都是“库”...例如
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net5.0</TargetFramework>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12064 次 |
| 最近记录: |