发布ASP.Net Core项目失败,出现下一个错误:
"DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 2 item(s).
They must have the same number of items.
当我尝试将ASP.Net Core网站发布到Azure时出现错误。它在本地构建和运行良好。输出打印出来:
Task "Copy"
Task Parameter:
SourceFiles=
C:\Users\Mikael\Source\Repos\GoMap-Web\src\Web\appsettings.json
CopyToPublishDirectory=PreserveNewest
RelativePath=appsettings.json
TargetPath=appsettings.json
C:\Users\Mikael\Source\Repos\GoMap-Web\src\Web\appsettings.json
CopyToPublishDirectory=PreserveNewest
RelativePath=appsettings.json
TargetPath=appsettings.json
Task Parameter:DestinationFiles=C:\Users\Mikael\Source\Repos\GoMap-Web\src\Web\obj\Release\netcoreapp1.0\PublishTemp\PublishOutput\appsettings.json
Task Parameter:OverwriteReadOnlyFiles=False
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Publish.targets(100,5): Error MSB3094: "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 2 item(s). They must have the same number of items.
Output Item(s): FileWrites=C:\Users\Mikael\Source\Repos\GoMap-Web\src\Web\obj\Release\netcoreapp1.0\PublishTemp\PublishOutput\appsettings.json
Done executing task "Copy" -- FAILED.
Done building target "_CopyResolvedFilesToPublishPreserveNewest" in project "Web.csproj" -- FAILED.
Done building project "Web.csproj" -- FAILED.
Microsoft.NET.Publish.targets文件(相关部分,我相信)看起来像这样:
============================================================
CopyFilesToPublishDirectory
Copy all build outputs, satellites and other necessary files to the publish directory.
============================================================
-->
<Target Name="CopyFilesToPublishDirectory"
DependsOnTargets="_CopyResolvedFilesToPublishPreserveNewest;
_CopyResolvedFilesToPublishAlways" />
<!--
============================================================
_CopyResolvedFilesToPublishPreserveNewest
Copy _ResolvedFileToPublishPreserveNewest items to the publish directory.
============================================================
-->
<Target Name="_CopyResolvedFilesToPublishPreserveNewest"
DependsOnTargets="_ComputeResolvedFilesToPublishTypes"
Inputs="@(_ResolvedFileToPublishPreserveNewest)"
Outputs="@(_ResolvedFileToPublishPreserveNewest->'$(PublishDir)%(RelativePath)')">
<!--
Not using SkipUnchangedFiles="true" because the application may want to change
one of these files and not have an incremental build replace it.
-->
<Copy SourceFiles = "@(_ResolvedFileToPublishPreserveNewest)"
DestinationFiles="@(_ResolvedFileToPublishPreserveNewest -> '$(PublishDir)%(RelativePath)')"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)"
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)">
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
</Copy>
</Target>
<!--
============================================================
_CopyResolvedFilesToPublishAlways
Copy _ResolvedFileToPublishAlways items to the publish directory.
============================================================
-->
<Target Name="_CopyResolvedFilesToPublishAlways"
DependsOnTargets="_ComputeResolvedFilesToPublishTypes">
<!--
Not using SkipUnchangedFiles="true" because the application may want to change
one of these files and not have an incremental build replace it.
-->
<Copy SourceFiles = "@(_ResolvedFileToPublishAlways)"
DestinationFiles="@(_ResolvedFileToPublishAlways -> '$(PublishDir)%(RelativePath)')"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)"
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)">
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
</Copy>
</Target>
我根据另一篇帖子更改了DestinationFiles="@(_ResolvedFileToPublishPreserveNewest -> '$(PublishDir)%(RelativePath)')"
,但我仍然遇到同样的失败,而且我对此没有足够的了解,发现任何明显错误,有人能提供一些见解吗?如果这受到其他帖子中提到的没有解决方法的错误的影响,我可以尝试将该应用程序发布到可能更好的azure上吗?