【发布时间】:2019-06-26 14:37:38
【问题描述】:
发布命令工作正常,但运行后,我必须恢复项目,因为缺少包...
所以如果我运行以下命令:
dotnet publish --runtime win-x64
然后发布工作,但我的项目中缺少包。
但是如果我在没有运行时的情况下运行发布:
dotnet 发布
然后发布工作正常,我没有任何丢失的包。
这是正常行为吗?我能做些什么来解决这个问题?这很烦人。
这是我的 csproj 文件:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup">
<Version>3.3.6</Version>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.App">
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.StaticFiles">
<Version>2.1.1</Version>
</PackageReference>
<PackageReference Include="NSwag.AspNetCore">
<Version>12.0.13</Version>
</PackageReference>
<PackageReference Include="NSwag.MSBuild">
<Version>12.0.13</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyProject.Analytics\MyProject.Analytics.csproj" />
<ProjectReference Include="..\MyProject.ApiClient\MyProject.ApiClient.csproj" />
<ProjectReference Include="..\MyProject.CommonApi\MyProject.CommonApi.csproj" />
<ProjectReference Include="..\MyProject.Common\MyProject.Common.csproj" />
<ProjectReference Include="..\MyProject.DbAccess\MyProject.DbAccess.csproj" />
<ProjectReference Include="..\MyProject.Logging\MyProject.Logging.csproj" />
<ProjectReference Include="..\MyProject.Messaging\MyProject.Messaging.csproj" />
<ProjectReference Include="..\MyProject.Model\MyProject.Model.csproj" />
<ProjectReference Include="..\MyProject.Settings\MyProject.Settings.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.Api.Development.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.Api.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.Api.Production.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include=".ebextensions\never-sleep-again.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.Api.PreProduction.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="MyProjectlogs\Development" />
</ItemGroup>
<ItemGroup>
<ProjectCapability Include="SourceItemsFromImports" />
</ItemGroup>
<Target Name="NSwag" AfterTargets="Build">
<Copy SourceFiles="@(Reference)" DestinationFolder="$(OutDir)References" />
<Exec Command="$(NSwagExe_Core21) run nswag.json /variables" />
<RemoveDir Directories="$(OutDir)References" />
</Target>
编辑:从还原 nugets 日志中,我获得了我发布的项目的每个依赖项的以下内容
@ Project 'MyProject.Api' is affected (InstallCount = 0)
所以它实际上认为有些东西不同,但似乎没有安装任何东西。
【问题讨论】:
-
您的项目中是否有 32 位依赖项?如果您将 64 位作为目标,我猜这些将不会发布
-
我该如何检查?我只添加了掘金。
-
缺少什么 dll?你能分享minimal complete example吗?我创建了一个新的 mvc 应用程序,添加了相同的包引用,并发布了它对我来说看起来不错。
-
查看问题中编辑的 nuget 还原日志,似乎没有“安装”任何东西。我真的对这个问题感到困惑。
标签: asp.net-core nuget publish