我无法发布 netcoreapp3.1 控制台应用程序,因为它试图找到一个(依赖)项目程序集,bin\x64\Release\netcoreapp3.1\win-x64
而实际上依赖程序集可以在bin\x64\Release\netcoreapp3.1
.
我可以毫无问题地构建和运行项目。
控制台应用程序的项目文件(MyService
)如下:
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<Platforms>x64</Platforms>
</PropertyGroup>
<ItemGroup>
<Compile Remove="FileLogProvider\**" />
<Content Remove="FileLogProvider\**" />
<EmbeddedResource Remove="FileLogProvider\**" />
<None Remove="FileLogProvider\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Dapper.Contrib" Version="2.0.35" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.9" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.7.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyService.PluginBase\MyService.PluginBase.csproj" />
</ItemGroup>
</Project>
并且引用的项目类库为 ( MyService.PluginBase
) 为:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<Platforms>x64</Platforms>
</PropertyGroup>
</Project>
我只打算在 Windows Server 上运行它,因此我有一个调试和发布解决方案配置,每个配置都有一个 x64(仅限)解决方案平台。
我想发布到单个文件并预编译为 x64,这是我设置发布设置的方式,但是当我发布时出现以下错误:
1>Metadata file 'C:\<path>\MyService\MyService.PluginBase\bin\x64\Release\netcoreapp3.1\win-x64\MyService.PluginBase.dll' could not be found
所以:
bin\x64\Release\netcoreapp3.1\win-x64
为什么它实际上位于更简单的文件夹中时寻找引用的程序集bin\x64\Release\netcoreapp3.1
?它显然是 x64 编译的,因为那是bin
.为什么应该有两个明确的
x64
文件夹级别(x64
和win-x64
)?我相信一个是平台配置,另一个是“RuntimeIdentifier”,但两者有什么区别?如何“修复”我的发布配置?