Visual Studio Successfully Using Shared Project wwwroot Files on Publish but not on Build/Run - shared-project

The Background
I'm working in Visual Studio 2019. I have a C# Web APP Razor Pages project which references several C# Class Projects and one C# Shared Project for files common across several other related Web App projects.
The Problem
When I publish the web app project to my local or a remote IIS instance, no problem, the shared project files, all of them, are present and accounted for and work as expected.
However, when I "just" build/run then view it in the browser, the shared project Helper and Pages are as expected, but the shared project wwwroot files are all missing in action.
The Want
I could, but do not wish to have to, publish locally every single time I need to see / troubleshoot anything that's in the shared project, so ...
I would like to find a way for the shared project wwwroot folder assets to be useable on Build/Run -AND- to be able to do it in such as way as to not to adversely impact the Publish process in which it is currently working as expected.
The Deets
The example folder structure for the relevant projects (probably tmi but detailed enough that if I have to do soemthing with paths from one project to the other, these relative paths would be correct enough for an example to be made) ...
inetpub
wwwroot
MyNameSoftware
wwwroot <-- all wwwroot files from both web app and shared projects end up here on Publish, yay
MyName
MyName.Common.Domain
MyName.Common.Domain.csproj file
various folders and sub-folders with classes
MyName.Common.Presentation.Web
MyName.Common.Presentation.Web.shproj file
Helpers <-- works fine
Pages <-- works fine
wwwroot <--- these files are available on Publish but NOT on Build/Run
aContainerFolder
other irrelevant stuff and things
MyName.Software
MyName.Software.sln
Various other MyName.Software.{Purpose} folders for related projects included in solution
MyName.Software.Web
various other folders and sub-folders
wwwroot <-- these files are available as expected on both Build/Run and Publish
MyName.Software.Web.csproj file
Where to go from here
As I was laying out what I'd tried and the questions I had, some things fell into place. Love the process, hate the pre-process hair-pulling. So I've answered my own question here, but will go ahead and post this so I can refer back to it later and so maybe it will help someone else keep a few hairs. Also, if there are other ways to do this, bring 'em on -- always good to consider alternatives. :0)

After research and putting bits and pieces together...
... the following is working for me on Build/Run and on Publish (be it via right-click-project-select-publish or via command line msbuild w/ deploy on build).
(1) store files destined for wwwroot in another folder, say, _wwwroot, and adjust the project files so they don't get published directly:
web app project's .csproj:
<ItemGroup>
<Content Remove="_wwwroot\**\*" />
</ItemGroup>
shared project's .projitems (note the absence here of CopyToPublishDirectory or CopyToOutputDirectory tags):
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)_wwwroot\**\*" />
</ItemGroup>
(2) add build events to the web app project
a pre-build event to remove everything in the web app project's wwwroot folder (so each build starts with a clean slate)
rd /s /q "$(ProjectDir)wwwroot"
and 2 post-build events in each web app project
xcopy /E /Y /I "$(ProjectDir)_wwwroot" "$(ProjectDir)wwwroot"
xcopy /E /Y /I "$(ProjectDir)..\..\..\MyName.Common.Presentation.Web\_wwwroot" "$(ProjectDir)wwwroot"
(3) set each web app project's wwwroot to be ignored on check-in to source control since the _wwwroot folders will be checked-in and will be considered the source of record
(4) reference everything that will be in the wwwroot folder normally, just as if they are always there since they will be present in wwwroot when needed

Related

Can't use Git Pages

TLDR: GitHub Pages isn't working.
I have a little knowledge on GitHub and tried multiple fixes to no avail. One repository is only showing readme file contents.
Please explain in lamest terms.
New to web development, I finally was able to complete my first site, but I'm unable to actually deploy the files for some reason; please forgive me, I literally have no idea what any of the git terminologies are.
I purchased a pro subscription in order to keep the repository private and the site public.
Every file is present in what seems to be the main root directory, but nothing is being actually presented.
I've created two different repositories in an effort to fix this, as I've seen different methods are available.
The first repository includes a README file because I was originally instructed to do so, however, all the site link does is present that README file's contents;
I also attempted to add a permalink fix within the file, but all it did was add that text to the other text presented.
The second repository in question literally greets me with nothing but a 404 error.
The solution I tried for the second repository was to have the repository name share my username as well since that seems to be where the site's link originates, but no present changes have occurred.
Finally, the waiting game solution hasn't beared any fruit yet either aside from updating the README file's contents.
All help is very much appreciated.
Check first:
Your GitHub repository name, which depends on the type of GitHub Pages you are creating
If you're creating a user or organization site, your repository must be named <user>.github.io or <organization>.github.io.
your GitHub Pages Publishing source
If you use the default publishing source for your GitHub Pages site, your site will publish automatically. You can also choose to publish your site from a different branch or folder.
You can add more pages to your site by creating more new files.
Each file will be available on your site in the same directory structure as your publishing source.
For example, if the publishing source for your project site is the gh-pages branch, and you create a new file called /about/contact-us.md on the gh-pages branch, the file will be available at https://<user>.github.io/<repository>/about/contact-us.html.
Make sure you have GitHub Pages enabled for every repository and that it's set to the branch you want to publish by checking your Pages settings at github.com/<user>/<repo>/settings/pages. If enabled, there should be a link on that page that takes you to the site.

Generated resources directory JetBrains PhpStorm and WebStorm

Is it possible to mark a directory as generated, so it will be excluded in the search indexing, but still uploads files automatically to an FTP when changed?
More specific: In my project I have a src and a dist folder, so while working in src I don't need any file suggestions for dist files in the search. Marking the directory as 'excluded' seems to work, but then it does not upload external changes to the FTP anymore when compiling the code (using webpack/gulp/babel). So now I need to upload everything manually on each change.
The reason I need to exclude the dist folder is because not all files in there are minified, and I sometimes find myself working in dist without noticing, because they're so similar.
Is there a way to get a combination of both features?
Is there a way to get a combination of both features?
AFAIK -- Not really.
You can mark files as Plain Text in your dist folder .. but it will have to be done on per file basis (which is a real PIA if you need to do this for lots of files or often)...
For JavaScript files you may try adding them as JavaScript Library files.
Otherwise -- only mark such folder(s) as Excluded. Not sure about automatic upload ... but manually invoking Deployment | Synchronize with Deployed... works (which you may be using anyway).
https://youtrack.jetbrains.com/issue/IDEABKL-4253
https://youtrack.jetbrains.com/issue/WEB-12345
Watch these and related tickets (star/vote/comment) to get notified on any progress.
Check all the comments in those tickets as well -- maybe you will find better/working-good-enough workarounds there.

Upload files from external library?

I've added my cms as an external library in PhpStorm:
I just wanted to know if there is an option to upload (deploy) these files too? I always have to switch to my cms and open it itself as a project to be able to upload its files.
I've found nothing in the documentation also.
If it's not part of the project root/outside of the project -- then no.
But you can make it part of the project by:
adding it as Additional Content Root (Settings/Preferences | Directories) -- it will be listed as additional node in the Project View panel (similar to actual project's main folder)
or just symlink it (e.g. a subfolder inside the project root that is symlink to outside folder).
Please note that in both cases such folder becomes part of the project so the search routine will take those files into consideration as well as other functionalities (find usages; look for errors in a code; TODO's etc.). You may also accidentally edit your CMS core files and IDE will not tell you anything (in case of External Library it will notify you about this).

How do I configure a Web Application project for working with html pages without .Net code?

We have a few html pages in one of our solutions that are meant to be extremely simple, client side only, pure html+javascript pages that access our web api. The api itself is in a web application project in the same solution.
We are now using a web site project to contain those files, but it is getting harder and harder to manage that project, since it's information is placed on the solution, and most of it's aspects cannot be controlled like they can on a msbuild project file.
I'd like to migrate those html files to a web application project, but I'm struggling to make it as basic as possible. For instance, I do not want to generate any dlls on the project. It should be in the solution just to provide access to the files and to enable us to control what goes to the _PublishedWebsites folder on the build by setting the build action on the files. We need this because there are some miscellaneous files in the project that should not be published.
I tried creating an empty web application and removing most things from it, by editing the csproj file. I managed to delete all references and the whole Properties special folder (along with the AssemblyInfo.cs file), but when I run the build command, I still see a dll created along with the obj and bin folders. Then, I tried faking the build target on the csproj file, like this:
<Target Name="Build" />
Now when the project is built, no dll/pdb is created, but the obj and bin folders are still there. Next, I tried setting the outputpath property to the current directory, like this:
<OutputPath>.</OutputPath>
But even then, the obj folder is still created.
EDIT:
I just found another common msbuild property that controls where the files inside the obj folder are placed. After placing this in my csproj file:
<IntermediateOutputPath>.</IntermediateOutputPath>
I now get no folders generated on build, which is nice.
There is a small problem now though (and I'm not sure how and where exactly this process happens) when I open the solution or reload the project in Visual Studio. Even though the project is not being built at this time, some files are still generated:
I feel the current approach is enough for my requirements, yet I'd really like to know if there is a more elegant way to achieve that. Thus, the question holds: Is there a way to make the web application project work as if there was no code file in it, effectively disabling output generation (bin and obj folders, and the dll/xml/pdb outputs)?

Visual Web Developer Publish doesn't publish all required files

With an MVC C# app that builds error-free, the Publish action (Release configuration) won't copy any of the controllers and several of files when "Publish only files required to run..." is selected.
Yes, MVC 1.0 is installed on top of ASP.net 3.5 SP1, and the MVC templates are visible in VWD. I'm at a loss as this is so simple. Any ideas?
Look at the properties of each file and make certain it states to copy when newer or copy always.
It may be set to "Don't copy"
I haven't done an MVC application myself, but I do know that when you publish a plain jane asp.net application all of the files are compiled down to an assembly and placed in the bin folder of your application.
You might want to check the folder you're publishing to and see if you have that bin folder and see if you have a .dll inside of there. If not, this could possibly be your problem.
Good luck and hope this helps you.