I´m deploying a project in c# windows forms project, that have a file in bin\Release folder that is needed to run correctly the app(it has some configurations to the use of a dll). when i run the app everything is ok. but if I try to deploy using visual studio, and add the file to the Apllication Folder, doens´t work. (no error messages, it happens exactilly the same if take that file from the bin\Release folder)
How can I deploy the project correctlly ?
config files for DLLs are not used in deployed applications. If you need to tweak the configuration of your dll, copy the corresponding sections to the exe config file.
Only the main assembly configuration is taken.
First, you will need to include the file in your solution.
Then, you need to set the Copy To Output Folder property to "Copy Always" or "Copy if Newer".
Related
I have a C# project which is basically a GUI used to call other executable(s) with command line arguments. (The command line exe was actually built with cygwin and uses the cugwin DLL).
So the directory structure that needs to exist once the app is deployed (via setup.exe or whatever) is this:
install dir ---> MyApp.exe
MyApp.config
(dir) bin ---> cmd1.exe
cmd2.exe
cygwin.dll
Now this ought to be simple, but whatever I try, I cannot get the bin directory and its contents to be copied when I install on a second machine with setup.exe. I tried:
- adding them as resources
- setting "Build Action" to Content
- setting "Copy To Output Directory" to Always
But the bin directory was never copied across when I did this. I have tried searching here and elsewhere but I am still at a loss.
Should this be a "ClickOnce" project? (what does this even mean - are there also ClickTwice and ClickUntilYouCanClickNoMore projects - ok, excuse me ...)
Also do I get setup.exe to put this app somewhere sane like C://Program Files/MyOrg/Myapp - instead of being buried somewhere in the user's profile?
(Using VS 2019.)
Since I cannot add an image in a comment, I am adding them here. Here is how my folder structure looks like.
I have a .p12 file and have marked it as "Copy to Output Directory" to "Copy always"
When the project is built, the file gets copied inside bin folder with the file's folder structure which includes "keystore" folder as well.
As a curiosity, I just tried out renaming my folder "keystore" to "bin" (I had to delete existing bin folder), and then added the .p12 file to it. The project compiled, generated new exe file and also copied .p12 file with appropriate folder structure. I am not sure what means to building and generating a Setup.exe though. You can try and let us know if it worked for you.
To package the specified file into ClickOnce, you just need to add it to Application Files....
The following is the folder structure.
And then confirm it has been added into Application Files....
Last step, publish it. And you can access the image like this.
private void button1_Click(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + #"/img/a.jpg");
}
As to put this app somewhere sane, I am afraid the answer is no.
ClickOnce's installation path cannot be changed. You can find it at C:\Users\username\AppData\Local\Apps\2.0.
When I build a windows application. It does not work because it cannot read my app.config file. I looked in the bin directory and it does not have the appname.exe.config file. If I manually copy over the app.config and rename it the appname.exe.config the application will work..but when I build the project this file is never created automagically. What am I missing? Why is my project not creating it? I have looked through the whole folder structure and there is no other config files.
Everyone here is giving you false information I think. I think #bowlturner had it right. According to Microsoft, you do need to set the app.config's Copy to output directory property to either Copy Always or Copy if newer. From Microsoft's MSDN Site:
When you develop in Visual Studio, place the source configuration file for your app in the project directory and set its Copy To Output Directory property to Copy always or Copy if newer. The name of the configuration file is the name of the app with a .config extension. For example, an app called myApp.exe should have a source configuration file called myApp.exe.config.
Visual Studio automatically copies the source configuration file to the directory where the compiled assembly is placed to create the output configuration file, which is deployed with the app.
The correct settings are:
Build Action = None
Copy to Output Directory = Do not copy
and very important, the project file needs to contain this element:
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
The only thing that worked for me was to delete bin\ and obj\ entirely. Rebuild and the file is created fine.
Look on App.config properties, should be:
BuildAction: None
CopyToOutputDirectory: Do not copy
Custom tool and custom tool namespace should be empty
Also try to Rebuild project. Right click on project -> Rebuild
Assuming you're using Visual Studio click your config file in the Solution Explorer and and in the Properties panel set Copy To Output Directory to something other than Do Not Copy.
My solution has two exe apps inside. Console application (Console.exe) and wpf application (MyUI.exe). Wpf application is a startup project, and console one is a small installation tool. Both have app.config file which contains db info. I have problem with this config file after I build the solution. In bin folder I have my wpf app and config file with the same name, e.g.:
MyUI.exe and MyUI.exe.config.
But there is no config file for console application. Is there any setting I should set to make it right?
When I set build action to content and copy to output... to Copy always then I have "App.config" file in bin directory, but there is no "Console.exe.config".
There is no such thing as a solution output folder - each project has it's own output folder, in which the App.config will be placed (after it's renamed to [exe_name].config).
I added 3 html files to my project and the change is reflected in my csproj file.
But to deploy this on to a web server, is it enough if I drop these 3 files in the appropriate directory? Or is there any build/assembly deploy needed because of csproj change?
Html files do not require build, just copy the files
IF you have code behind for aspx files then you need to deploy the dll.
Add the file to your project.
Set the build action to "content".
Set "copy to output directory" to "copy always".
The file should be included in the same folder as the rest of your deployment. You should be able to see it by building it and looking in the \bin\release or the \bin\debug folder. If it's not there, click on the Application Files button and see if it shows up there.
Deploying the HTML files to your web server simply requires you copy the HTML files to the appropriate directory.
The resulting change in your .csproj was really only made to keep track of the files within your IDE but no, you wouldn't need to rebuild/redeploy the resulting DLL just for static files.
I kept getting errors in my log file that messageconfig file not found. It turned out that my application was expecting it in the bin\debug folder. What causes the application to expect so? It seems that when project is built it should copy the config file in bin\debug folder. Am i missing a certain project setting?
App/web.Config files are expected to be in the same directory as the application/web root.
Other, referenced config files may be in other directories, as specified in the main configuration file.
If you right click on the .config file, then on properties there is a Copy to Ouput Directory entry.
This should be set to either Copy if Newer or Copy always, if this is set to Do not copy, the .config will not by copied to the debug/release folder where it is expected.
Config files are expected to be in the same location as the executing assembly.
Check out this SO question:
.NET 2.0 Application Settings (user.config) file location
You could set the files build action to "Copy always"..
usually you only need the .exe. Try to clean and rebuild your project..
Hope it helps