我正在将项目升级到 .net 5,但在构建时遇到了最奇怪的错误。
<ResolvePackageAssets
ProjectAssetsFile="$(ProjectAssetsFile)"
ProjectAssetsCacheFile="$(ProjectAssetsCacheFile)"
ProjectPath="$(MSBuildProjectFullPath)"
ProjectLanguage="$(Language)"
EmitAssetsLogMessages="$(EmitAssetsLogMessages)"
TargetFramework="$(TargetFramework)"
RuntimeIdentifier="$(RuntimeIdentifier)"
PlatformLibraryName="$(MicrosoftNETPlatformLibrary)"
RuntimeFrameworks="@(RuntimeFramework)"
IsSelfContained="$(SelfContained)"
MarkPackageReferencesAsExternallyResolved="$(MarkPackageReferencesAsExternallyResolved)"
DisablePackageAssetsCache="$(DisablePackageAssetsCache)"
DisableFrameworkAssemblies="$(DisableLockFileFrameworks)"
CopyLocalRuntimeTargetAssets="$(CopyLocalRuntimeTargetAssets)"
DisableTransitiveProjectReferences="$(DisableTransitiveProjectReferences)"
DisableTransitiveFrameworkReferences="$(DisableTransitiveFrameworkReferences)"
DotNetAppHostExecutableNameWithoutExtension="$(_DotNetAppHostExecutableNameWithoutExtension)"
ShimRuntimeIdentifiers="@(_PackAsToolShimRuntimeIdentifiers)"
EnsureRuntimePackageDependencies="$(EnsureRuntimePackageDependencies)"
VerifyMatchingImplicitPackageVersion="$(VerifyMatchingImplicitPackageVersion)"
ExpectedPlatformPackages="@(ExpectedPlatformPackages)"
SatelliteResourceLanguages="$(SatelliteResourceLanguages)"
DesignTimeBuild="$(DesignTimeBuild)"
ContinueOnError="$(ContinueOnError)"
PackageReferences="@(PackageReference)">
我正在使用 SimplyCommerce 中的包来创建模块化网站,但收到此错误。
Severity Code Description Project File Line Suppression State
Error MSB4044 The "ResolvePackageAssets" task was not given a value for the required parameter "TargetFramework". SimplCommerce.Module.PaymentPaypalExpress C:\Program Files\dotnet\sdk\5.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 241
当我查看程序集详细信息时,我已将其重命名为仓库 crm,但当我查看目标框架时,它显示为空白。尽管我之前已经设置过,但 .net 5 是运行最新 Visual Studio 的工具中的一个错误,当我双击该错误时,它会将我带到此文件
C:\Program Files\dotnet\sdk\5.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets
在您询问之前,.net 5 已安装在目标计算机上。
这是有问题的库的 csproj 文件,您将看到它们不是框架版本,因为它是 razor sdk 库
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Content Remove="bundleconfig.json" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="bundleconfig.json" />
</ItemGroup>
<ItemGroup>
<Folder Include="Areas\PaymentPaypalExpress\Components\" />
<Folder Include="Areas\PaymentPaypalExpress\Views\Shared\Components\" />
<Folder Include="Data\" />
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Warehouse.Infrastructure\Warehouse.Infrastructure\Warehouse.Infrastructure\Warehouse.Infrastructure.csproj" />
</ItemGroup>
</Project>
最佳答案
在 .csproj
文件中添加目标框架将解决该问题。
对于.NET 5
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
对于.NET 6
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
所有其他版本,另请参阅MSDN - frameworks
关于c# - 升级到 .net 5 程序集缺少框架版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65181472/