jfgibson
jfgibson

Reputation: 1

Visual Studio 2019 Python Publish to File System Fails

I have been unable to "Publish" a Python application to a local filepath with Visual Studio 2019. The intent is to host the application under IIS on a Windows 2016 Server. PC is running Windows 10 build 1909.

I have updated VS 2019 to version 16.9.2, with the Python product being version 16.9.21026.1.

The test application is an unmodified "Flask Web Project" template, which runs as expected in the Visual Studio environment.

I have attempted publishing to the default ".\app.publish" file path, i.e.

"C:\Apps_VS2019\FlaskDemoApp\FlaskDemoApp\app.publish", and to "C:\Apps_VS2019\Pub"

In both cases all users have been granted Full Control permissions.

The Publish command reports success publishing to e.g. "C:\Apps_VS2019\Pub" but no files are written to that path. I do see some files copied to "C:\Apps_VS2019\FlaskDemoApp\FlaskDemoApp\obj\Any CPU\Debug\Package\PackageTmp" but nothing makes it to the final publish folder. The .\PackageTmp folder contains: Folder "FlaskDemoApp", and files "requirements.txt" and "runserver.py". The "FlaskDemoApp folder contains: "static", "templates", "init.py", and "views.py", with the static and template folders containing expected files / subfolders.

What I do not see in the .\PackageTmp folder are any of the required packages "click", "Flask", "itsdangerous", "Jinja2", "MarkupSafe", Werkzeug" etc. (Should they be there?)

FolderProfile1.pubxml in "C:\Apps_VS2019\FlaskDemoApp\FlaskDemoApp\PublishProfiles"

Content:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
  <DeleteExistingFiles>False</DeleteExistingFiles>
  <ExcludeApp_Data>False</ExcludeApp_Data>
  <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
  <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
  <LastUsedPlatform>Any CPU</LastUsedPlatform>
  <PublishProvider>FileSystem</PublishProvider>
  <PublishUrl>C:\Apps_VS2019\Pub</PublishUrl>
  <WebPublishMethod>FileSystem</WebPublishMethod>
  </PropertyGroup>
</Project>

The VS project has always been in Debug / Any CPU configuration, so it is not at all clear why is set to "Release". However there is no Release folder or Debug folder.

Bottom line: Any ideas why the publish is "successful" but there are no files in the target path? And does the "PackageTmp" folder described above have everything it should? Where are the external packages supposed to be, such as "Flask" and "Jinja2"?

Upvotes: 0

Views: 379

Answers (1)

jfgibson
jfgibson

Reputation: 1

I have at least a partial answer to my own question. The build configuration in VS is "Debug" "Any CPU". In the publish profile the "Configuration" parameter was set to "Release". I had to manually change that setting to "Debug". Now, upon publishing I am getting a file set in the publish path. That file set contains folders "static" and "templates", and files "_ init _.py" and "views.py".

I am still uncertain about the external packages, e.g. "Flask" and "Jinja2", but I suspect that those need to be dealt with separately, in setting up the Python environment on the server. I will begin researching that. At least I now get files in my publish target path.

Upvotes: 0

Related Questions