MSDeploy: How to delete a single file on remote server - msdeploy

How do I delete a single file on remote server. I want to delete offline_app.htm only leaving the rest of the content in tact.
Tips appreciated.

What you're looking for is -verb:delete
msdeploy -verb:delete ^
-dest:contentPath="Default Website\offline_app.htm",computer=etc

Related

.NET Core - same project running under iis express on different drive

I recently bought a new computer. I moved the drives from my old computer to the new one, installed everything I needed to and opened my project. Now I'm trying to run my project in IIS express but it displaying an error specifying an html output as log file.
When I look at the html problem, it's a 500 error message generated by what looks likes an IIS page. It's saying that the config file cannot be found:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid
Config File
\\?\F:\Development\MyProject\API\web.config
When I switched to the new machine drive letters were changed, so the code I'm running is no longet on drive F like in the message above - it's now on a different drive. I've looked in my code - I have no reference anywhere to a specific path.
I've tried to do clean and rebuild but it doesn't work.
If I look inside files for the path I see that the DLLs are compiled with PDB file path inside them. Why is that? And what happens later on on production?
Also, how do I fix this problem? why does it keeps looking for old location?
I'm fairly sure the IIS Express metabase still has the old path configured for this site. Please see the following answer for how to locate the metabase file (it's usually here: \Documents\IISExpress\config\applicationhost.config):
Where is the IIS Express configuration / metabase file found?
I'm not sure what the most correct way is to correct the problem, but you should be able to manually edit this file and update the "physicalPath" attribute for your site to the correct path to resolve this problem.
I don't know the exact cause of my problem, but the solution was to delete all bin directories from all project folders and re-compile.
To delete the bin directory from all my project I wrote the following PowerShell script:
Get-ChildItem -Path . -Filter *bin* –Recurse | Remove-Item -Recurse -Confirm

How to handle path on azure for XmlDocumentationProvider

I am using azure for deployment of my new Web API's, I am new with deployment on IIS and azure.
I have added my Web API's on azure as web application, and it's working fine, till I added documentation for each API's functions. After adding description I uncomment line below from HelpPageConfig.cs.
config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));
It's working finr locally, and I am able to see all descriptions, but when I published it on azure, I am getting error saying,
Could not find a part of the path 'D:\home\site\wwwroot\App_Data\XmlDocument.xml'.
site url : http://mejodo.azurewebsites.net/
Do I need to change path ?
File is already created in my system on D:\home\site\wwwroot\App_Data directory.
What changes I need to do to make it work ?
I had the same issue. For me the file was generated. Please follow the below steps.
Click on show all files in solution explorer.
Check whether you have a file in App_Data folder
If you have the file, right click and include the same in your project.
Now build and publish to Azure.
I hope this will work. Thanks
In my case XmlDocument.xml had to be added in Visual Studio to the App_Data folder within the solution using 'add existing item'.
Just add to your project new folder "App_Data" with XmlDocument.xml and publish
When you say that you have Web API's on azure as web application, do you mean that they are applications under the site ? If yes, then I think you are missing the application name in the path to the XML file.
Try going to mejodo.scm.azurewebsites.net > debug console > powershell to see the exact folder structure....
You must verify that the line in the HelpPageConfig.cs file in the Area>HelpPage>App_Start folder.
that is in the register method, this line is
config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));
this uncommented
then you must verify that in the project configuration, in the build XML documentation file, this is the same path as the above mentioned line.
When you publish the xml file goes in the bin folder, so change 'D:\home\site\wwwroot\App_Data\XmlDocument.xml'.
to
'D:\home\site\wwwroot\bin\XmlDocument.xml'.
and it should work.

Is it possible to modify web.config of existing site using MSDeploy?

Is it possible to modify (or just replace) web.config of existing site using MSDeploy?
It's possible to replace certain sections (specified with an xPath query or regular expression) of the web config file. Use the -declareParam en -setParam commandline switches for that.
Like so
msdeploy -verb:sync -source:apphostconfig="Default Web Site" -dest:package=ParameterPackage.zip -declareParam:name=param,kind=XmlFile,scope=web.config,match=//add/#value
or so:
msdeploy -verb:sync -source:package=ParameterPackage.zip -dest:auto -setParam:name=param,value=MyDefaultWebPage.htm
You can find more info here if you're using the command line.
If your working with importing and exporting packages in and from IIS you can create a parameters.xml file. Vishal Joshi has lots of good posts about how to use msdeploy (for example this)
Yes you can do this. I just posted a blog on this at http://sedodream.com/2012/02/14/HowToUpdateASingleFileUsingWebDeployMSDeploy.aspx but I'm also copying the content below for you.
The other day I saw a question posted on StackOverflow asking if it was possible to update web.config using MSDeploy. I actually used a technique where I updated a single file in one of my previous posts at How to take your web app offline during publishing but it wasn’t called out too much. In any case I’ll show you how you can update a single file (in this case web.config) using MSDeploy.
You can use the contentPath provider to facilitate updating a single file. Using contentPath you can sync either a single file or an entire folder. You can also use IIS app paths to resolve where the file/folder resides. For example if I have a web.config file in a local folder named “C:\Data\Personal\My Repo\sayed-samples\UpdateWebConfig” and I want to update my IIS site UpdateWebCfg running in the Default Web Site on my folder I would use the command shown below.
%msdeploy% -verb:sync -source:contentPath="C:\Data\Personal\My Repo\sayed-samples\UpdateWebConfig\web.config" -dest:contentPath="Default Web Site/UpdateWebCfg/web.config"
From the command above you can see that I set the source content path to the local file and the dest content path using the IIS path {SiteName}/{AppName}/{file-path}. In this case I am updating a site running in IIS on my local machine. In order to update one that is running on a remote machine you will have to add ComputerName and possibly some other values to the –dest argument.
You can view the latest sources for this sample at my github repo.

Nautilus script: $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS empty for WebDAV folders

When writing a Nautilus script, $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS gives the path to the file whose context menu has been clicked, for instance /home/nico/test.txt.
But when the file is within a WebDAV share, the variable is empty.
Is it a bug?
How to get the path for a WebDAV file?
My script is intended to be used for files on WebDAV shares.
I have just found this list of variables:
https://help.ubuntu.com/community/NautilusScriptsHowto
The one I was looking for is $NAUTILUS_SCRIPT_SELECTED_URIS, it works on WebDAV too, returning for instance dav://admin#localhost:8080/alfresco/webdav/User%20Homes/leo/test.txt
Nautilus' $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS is only for LOCAL (mounted) files, and by design is blank for remote files, like $1, $2...
For REMOTE files, like WebDAV, or Samba network shares, FTP servers, (or any other location where $NAUTILUS_SCRIPT_CURRENT_URI is not like file://...), use $NAUTILUS_SCRIPT_SELECTED_URIS

Put file at specific port on Localhost

I need to put a file at this address: http://localhost:51547/file.txt
What folder would I put it in on C:/?
Tony
If I understand your question correctly and you're trying to expose a file via the ASP.NET development server at that location (http://localhost:51547/file.txt) I'm afraid the answer is not quite to your liking.
Basically I don't think you can serve files from the root of the ASP.NET development server (i.e right after the localhost:port/ part - the port is automatically selected by ASP but you can also manually configure it). ASP.NET automatically creates a virtual application path right after localhost:por> and so you're most likely going to be limited to serving files from the virtual application folder. So, assuming you web application name is: "testApp", if you put a file called file.txt in the directory where you're storing the source code for "testApp" it will also become available when you're testing at: http://localhost:port/testApp/file.txt (note the testApp in between the host-name & port, and the file-name)
UPDATE
In light of you comment, here's something you could do. You could try to get a simple HTTP server installed on your development computer and have it serve files on a different port (say port 8000). In that case you would serve file.txt using this secondary HTTP server and it would be accessible at: http://localhost:8000/file.txt.
You could try to install Apache or use IIS which comes with Windows. For Apache, the quickest way to get it going would be to install a WAMP environment. You may also try Lighttpd, and also note that MySQL or PHP are not required at all if you're only serving static files.
Any folder you want. The port designator is specified in IIS itself.
http://support.microsoft.com/kb/149605
I suggest you that if you want to do a site(HTTP) is better to use the port 80 or to do a redirection for another port, remember too that localhoost is a loop back and also take a look at PortForward to check some ports that are used by specific applications and types of servers, and please improve your question.
Regards.

Resources