我使用.csproj文件将带有project.json文件的.NET Core 1.0项目迁移到Net Core 1.1项目。在.csproj文件的末尾,我有以下内容:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Tools" Version="1.1.0-preview4-final" />
<DotNetCliToolReference Include="Microsoft.AspNetCore.Server.IISIntegration.Tools" Version="1.1.0-preview4-final" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.1.0-preview4-final" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.1.0-preview4-final" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="Prepublish" BeforeTargets="PrepareForPublish" Condition=" '$(IsCrossTargetingBuild)' != 'true' ">
<Exec Command="npm install" />
<Exec Command="bower install" />
<Exec Command="gulp clean" />
<Exec Command="gulp build" />
</Target>
<Target Name="Postpublish" AfterTargets="Publish" Condition=" '$(IsCrossTargetingBuild)' != 'true' ">
<Exec Command="dotnet publish-iis --publish-folder $(TargetDir) --framework $(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion)" />
</Target>
发布项目时,我在dotnet publish-iis上收到错误:
exited with code 1.
我试图找到错误,我发现的唯一一件事就是:
System.IO.FileNotFoundException: Could not find file 'C:\MVCProj\project.json'.
但是,如果我使用.csproj,为什么要查找project.json文件?
答案 0 :(得分:2)
如果您仍在寻找答案,我发现不再使用publish-iis cli工具。
https://github.com/dotnet/cli/issues/4855#issuecomment-263799301
您需要从.csproj文件中删除对Microsoft.AspNetCore.Server.IISIntegration.Tools
包和whoe Postpublish
目标的引用。