Publish a file from an included project to App_Data - c#

I have an mvc project (A) and this has a reference to another project (B) which includes a specific dll. I need this dll to be published to the app_data folder of any project which references project B.
I have tried setting it's build action, and the copy to output directory, but this doesn't seem to help. I've made sure the app_data folder exists on the server, and can publish files which are directly in the app_data folder of project A.

i have met this problem. I solve like that; move manually app_data files in publish folder. If App_Data folder exist in publish folder copy and paste from project to publish folder. If not exist create manullay.

Keep the "copy to output directory" but note that will only put the dll in the bin output folder. However, from there you can copy it to App_data after the build: in the project properties, select the Build Events tab and add this to the post-build events (updating for your dll):
xcopy "$(ProjectDir)$(OutDir)your.dll" "$(ProjectDir)App_Data\" /Y

Related

How to copy an EXE from a .net core app's bin directory into wwwroot without knowing the build configuration?

I have an exe being dropped into my bin directory however sometimes this exe will be dropped into debug or release. Is there any way to - from a post-build event - say "hey, wherever we built this thing, copy it into the wwwroot folder"?
I see the following: http://www.benramey.com/2010/06/29/visual-studio-post-build-event-to-copy-dlls/
Where this code is used:
cd $(ProjectDir)
copy /y bin\debug\*.dll C:\inetpub\wwwroot\wss\VirtualDirectories\{YOUR SHAREPOINT SITE DIRECTORY}\bin
However I want to not specify debug or release or netcoreapp2.0 or netcoreapp:
How can this be achieved?
Use the provided macros. You already used $(ProjectDir).
$(TargetPath) will contain the complete path to the executable.
$(OutDir) will contain the output directory (relative).

Can't copy XML on Clickonce deployment

I have a solution with 2 projects:
MainSolution
Project A
Project B
Folder A
Settings.xml (Embedded R.->Copy Always)
But when I try to deploy it over ClickOnce, I got an error when the app starts, something like: "Could not find the .xml file", so the problem is basically that in the deployment part the file is not copied over the output directory.
I tried to:
*Change the output dir from my project B to the bin\debug in project A
*I included my project B as required in the app files for project A in the publish setting of my main project (Project A).
PS: The error is obtained when I tried to retrieve my settings in the fiel, I tried to use:
*Application.StartupPath + "\Folder\Settings.xml
*Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName) + "\Project B\Folder\Settings.xml"
Thanks, regards.
There is no "Project B" folder. When the application is deployed, everything would be in the "Project A' folder. Also, you have indicated that "settings.xml" file is an "Embedded Resource". Therefore that resource will be available via Assembly.GetManifestResourceStream Method.

How to create a folder in bin/Release for Visual Studio Project?

How to create a folder in bin/Release for Visual Studio Project?
My project calls external exe file, and I would like to place that
exe file in bin/Release/External. But every time I rebuild my project
everything is removed, so I can't just manually copy the file there.
How should I do it?
The folders inside the bin folder of your project are always deleted when you clean your solution (unless you change the project properties, but this won't solve your problem).
The simplest way of doing it is by adding the desired folder to your project and the exe file on the folder. Change the properties of the exe file to "Content" and "Copy always".
By doing that, everytime you rebuild your solution, the output will have the folder and exe file.
If the Exe file changes, you can add it as a link; ensuring you will have the latest version every time.
Or another way again..
Use Post build event where you write DOS commands.
For example in your case you can write:
mkdir $(TargetDir)\External
xcopy SOURCE_DIR_EXE $(TargetDir)\External\EXE_NAME
create a folder in the project, place the exe file in it, and set "Copy To Output Directory" property to "Copy if newer".
Just create a folder in your project, add a reference to your exe in that folder and then set the Copy to Output Directory property of the exe to Copy always / Copy if newer.
The folder structure of where the exe is will be replicated in the output directory.
Add mkdir command Post-build event command line in project options -> Build Events
You could Use a Post-build event for that.
Project Properties -> Build Events -> Post build event commandline "copy from a to b"
or second option, you create a folder "External" in your project and put your exe there. set the property "Copy to Output Direcotry" to "Copy always".
Try to integrate this into the build process:
<ItemGroup>
<_CopyItems Include="$(your_path)\*.*" />
</ItemGroup>
<Copy
SourceFiles="#(_CopyItems)"
DestinationFolder="$(BuildOutput)\External"
/>
Create a folder with your desire name in your solution, add your files there (Add Existing Item), right click on files and set BuildAction to None and CopyToOutputDIrectory to Copy Always or Copy If Newer, rebuild your project, that is it!

How to copy a file to application folder in set up project during insatllation. File is in set up folder

I have a xml file in the setup folder of a windows application. Now during the installation how do i copy this file to my application's folder so that it can be copied to this path C:\Program Files (x86).......
I can not add the file to the application folder in the setup project because the content of file might change after build of setup project.
Its an external xml file in located inside set up folder. and I want to copy this file on installation path(C:/Program Files...) during installation. I will give this file with msi installer in side installer folder.
Please provide any idea if someone have....
If I'm understanding you correctly, this might solve your problem, or at least get you started:
Include the file in the main project (for instance in a folder called "resources"). Right click the file in VS, choose properties, and set Copy to output directory to Coppy Always.

Publish dll - copy to bin folder

MVC project.
On my data access layer I have a libs folder where I store some dlls that the project needs t oaccess data. One of them is set "copy local" to true. The goal is to copy the dll to the bin folder so I can deploy it with the application.
The thing is, when I build the app, it does copy to the bin folder, but to the bin folder on the DAL project only. Since it is a web applicaiton I want to build the web project and have the dll copied to its bin folder so I can just deploy it withou having to manually coping it from the bin on the dal to the bin of the deployed appliation.
What do I need to do to accomplish that?
Build Action = Content might help; but then it will only come in to your DAL Bin if it is referenced there.
You can right click on the web project and than click on Deployment project as given below ..this will add all required dll for your project in the path of your poject which you can see in ouput window

Categories