Reputation: 3114
I'm having trouble getting dotnet publish-iis
to run correctly.
To publish my project I'm using:
dotnet publish ./src/RetailGuardian.Web/ -o ./code_drop/RetailGuardian.Web --runtime dnet452
and I've set a postpublish script in my project.json
:
"scripts": {
"postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
}
The initial publish works properly, and places the code in a code_drop directory as expected (this was what I used to deploy in RC1 and it worked fine). However, publish-iis seems to not use the output path when attempting to locate the web.config. This is the output from when it runs:
Configuring the following project for use with IIS: './code_drop/RetailGuardian.Web'
No web.config found. Creating './code_drop/RetailGuardian.Web\web.config'
Could not find a part of the path 'G:\Projects\retailguardian\src\RetailGuardian.Web\code_drop\RetailGuardian.Web\web.config'.
System.IO.DirectoryNotFoundException: Could not find a part of the path 'G:\Projects\retailguardian\src\RetailGuardian.Web\code_drop\RetailGuardian.Web\web.config'.
at System.IO.Win32FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
at System.IO.Win32FileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32
bufferSize, FileOptions options, FileStream parent)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at Microsoft.AspNetCore.Server.IISIntegration.Tools.PublishIISCommand.Run()
at Microsoft.AspNetCore.Server.IISIntegration.Tools.Program.<>c__DisplayClass0_0.<Main>b__0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.AspNetCore.Server.IISIntegration.Tools.Program.Main(String[] args)
publish: Published to ./code_drop/RetailGuardian.Web
Published 1/1 projects successfully
So it's trying to use G:\Projects\retailguardian\src\RetailGuardian.Web\code_drop\RetailGuardian.Web\web.config
which is the source directory, rather than G:\Projects\retailguardian\code_drop\RetailGuardian.Web\web.config
which is where the publish output is.
(Curiously it also reports that the publish was successful, even though the postpublish fails)
Upvotes: 4
Views: 1921
Reputation: 1853
My observation is, this happens when your terminal gets closed unexpectedly your server doesn't shut down properly. The simplest solution is start you application and stop it properly, and then try to execute the publish command.
execute the following sequence of commands :
dotnet start
ctrl + c
dotnet publish ..
Upvotes: 0
Reputation: 124
I had this issue and solved it by adding web.config in include -> publishOptions from project.json:
"publishOptions": {
"include": [
...
"web.config"
]
}
Upvotes: 0
Reputation: 31620
This seems to be a bug where a dotnet command resolves a relative path and then changes the current directory to invoke a tool which tries to resolve the path again but now it resolves it relative to a different folder so the final path is different. Thanks for reporting this - I opened an issue in the cli repo: https://github.com/dotnet/cli/issues/3528
Possible workarounds:
Upvotes: 6