The root of my problem is that I want to get HTTPS working for a Blazor app deployed to AWS Elastic Beanstalk. According to all the documentation I'm able to find, I need to add some config files to an ".ebextensions" folder. I've done that. I've marked them with a "Build Action" of "Content" and set "Copy to Output Directory" to "Copy if newer". I've even edited the "csproj" file and set the "CopyToPublishDirectory", trying both "true" and "PreserveNewest". None of these things have helped. The files get copied to the local "bin" folder properly as I'd expect. However, after running the "AWS Toolkit" to publish, the files never seem to make it to the server.
Any ideas?
Thanks in advance!
It turns out the files were being copied all along and are getting applied. I just didn't have enough visibility into the process, and the folder is either hidden or removed after use.
On to the next problem...
Now to get HTTPS actually working! 😀
Related
I'm pretty new to C# and SQL Server and I am working on an example for school using simple databases in Visual Studio 2019. I've connected to an external .MDF database file provided for the project and it's copied into my project folder (I've opted to place a copy of the database in the project folder).
Upon running my application, I make some changes to the data and save. Then on re-running the application, the data is the original data, without my previous changes. I've confirmed the save within the application works as the timestamp on the .mdf file in the debug folder is updated. However when I rerun, the .mdf file in the project folder is again copied to the debug folder.
I have set the "copy to output directory" property to copy always, copy if newer, and never copy, all with the same results. I assumed copy if newer would be the best option.
Any suggestions? For reference, the example is from "Starting out with Visual C#" 5th Edition by Tony Gaddis, chapter 12, tutorial 12-3. The tutorial doesn't mention the "copy to output directory" property and I'm not finding a resolution on other forums.
I found the reason I was running into this problem. I had erroneously changed the "copy to output directory" to "copy if newer" for the dataset (.xsd in solution explorer) rather than the database itself (.mdf in solution explorer).
Wanted to post in case other newbies ran into this issue.
Task is to form Visual Studio 2010 project so, that during any build or publish some foo.exe utility should be copied to output (bin) directory.
Early I have made PostBuildEvent task in .csproj (MSBuild-file):
<PropertyGroup>
<PostBuildEvent>
Copy "$(SolutionDir)Tools\foo.exe" "$(ProjectDir)$(OutDir)foo.exe"
</PostBuildEvent>
</PropertyGroup>
But this is not universal. During publishing (Visual Studio 2010) foo.exe appears in bin directory, but is not copied to output publish directory. Maybe I do everything completely wrong and there is standard mechanism to include files in projects to be later, during build or publish, copied to bin?
There is and it is not dependent on post build events.
Add the file to your project, then in the file properties select under "Copy to Output Directory" either "Copy Always" or "Copy if Newer".
See MSDN.
I only have the need to push files during a build, so I just added a Post-build Event Command Line entry like this:
Copy /Y "$(SolutionDir)Third Party\SomeLibrary\*" "$(TargetDir)"
You can set this by right-clicking your Project in the Solution Explorer, then Properties > Build Events
In Solution Explorer, please select files you want to copied to output directory and assign two properties:
- Build action = Content
- Copy to Output Directory = Copy Always
This will do the trick.
Add the file to your project.
Go to the Properties of that file.
Set "Build Action" to Embedded Resource.
Set "Copy to Output Directory" to Copy Always.
There is another way that can copy items that are "outside" the Solution (which also makes it technically possible to copy Solution Items as well).
In Solution Explorer, right-click in your project and choose "Add... Existing Item". Locate the file in question (it can by any type, not just code), and next to the "Add" button, click the drop-down arrow and select "Add As Link".
In Solution Explorer, select the item that was just added to your project and change the Copy to Output Directory property to Copy if newer or Copy always, as appropriate.
In my case, setting Copy to Output Directory to Copy Always and Build did not do the trick, while Rebuild did.
Hope this helps someone!
Try adding a reference to the missing dll's from your service/web project directly. Adding the references to a different project didn't work for me.
I only had to do this when publishing my web app because it wasn't copying all the required dll's.
Just so my fellow neuronically impaired comrades might chance upon it here, I had assumed that, for web projects, if the linked file was an external .config file that the "output directory" would be the same directory that web.config lives in, i.e. your web project's root. In retrospect, it is entirely unsurprising that it copies the linked file into the root/bin folder.
So, if it's an appSettings include file, your web.config's open tag would be
<appSettings file=".\bin\includedAppSettingsFile.config">
Duh.
After changing something in my C# code, I can run it without problem. However, if I run the .exe file in WindowsFormsApplication1/bin/Debug/, I would get an error message. By checking the 'Date modified' of this .exe file, I found it wouldn't update accordingly.
I then tried to do Build/Build Solution and Rebuild Solution but the .exe file would still not be updated.
Can you tell me how to update the .exe file?
To view the output directory for your builds, right-click on the project you are trying to build and select "Properties". Under the "Build" tab you should find the following:
At the top you can also see the configuration under which your project is building (usually Debug or Release). By default, the output directory for Debug and Release builds are, respectively, "bin\Debug" and "bin\Release". EDIT: To change which build configuration is currently active, you will need to go to Build -> Configuration Manager:
Once you have checked the build directory paths and the configuration which you are building, do a Clean Solution followed by a Build Solution and your *.exe file should now be the latest version.
Hope this helps!
Alex
EDIT:
Apologies - meant also to mention that the build directory paths are relative to the project directory (the directory where the *.csproj file for your project lives). So updating the *.exe file in WindowsFormsApplication1\bin\Debug under Debug configuration with the default output directory is contingent upon WindowsFormsApplication1.csproj being contained in the WindowsFormsApplication1 directory.
Somehow I figured out why it is happening. If you have multiple projects in a solution (I assume that's the case above), check the status of "Build" checkbox in the property pages. I faced same issue when one of my three projects under solution was not refreshing whenever I rebuild the solution.
Hope this will help!
I have some library files needed for my application to work.
My application has a setup and deployment included.
I already know that in order for a library file to be added to the output directory of the application when installing, I just have to reference those libraries inside the .NET IDE before building... the only problem is that these libraries can't be referenced... So I need to be able to copy these libraries to the installation directory of my application... At the moment, I am copying these libraries manually...
Addendum
I also did try to add these library files as an Existing Item to my project and marked each library files' Copy to Output Directory to Copy if newer on their properties but still not getting the solution I want.
Update 1
Thanks for you help guys it helped me solve my problem, I managed to make the solutions you posted work except for one... #Matthew Watson's post.. I even managed to find a solution too so I wanted to share it with you also.
Heres what I did:
I opened the setup and deployment project in my application.
Under the Application Folder Tree, on it's right side, I right clicked..
then clicked Add..
then clicked File
and then browsed for the files I wanted to add to the installation directory
and click open.
But out of curiosity...I am still trying to make what #Matthew Watson posted work...
Update 2
I forgot to update this post yesterday, I already manage to make Matthew Watson's solution worked yesterday. Thank you again for all your help guys.
You can add files to your project and select their properties: "Build Action" as "Content" and "Copy to output directory" as "Copy Always" or Copy if Newer (the latter is preferable because otherwise the project rebuilds fully every time you build it).
Then those files will be copied to your output folder.
This is better than using a post build step because Visual Studio will know that the files are part of the project. (That affects things like ClickOnce applications which need to know what files to add to the clickonce data.)
You will also be more easily able to see which files are in the project because they will be listed with the source code files rather than hidden in a post-build step. And also Source Control can be used with them more easily.
Once you have added "Content" files to your project, you will be able to add them to a Visual Studio 2010 Setup and Deployment project as follows:
Go into your Setup project and add to your "Application Folder" output the Project Output called "Content Files". If you right-click the Content Files after adding them you can select "outputs" and see what it's going to copy.
Note that Setup and Deployment projects are NOT supported in Visual Studio 2012.
You can use Visual Studio Post Build Event - Copy to Relative Directory Location. Which are basically scripts that are executed on build of specified project.
So you can use it to copy binaries you need, before actually running your application.
I have a few RDLC files in my WPF application. When I publish the project, the report files don't get published, and when I try to access them with the client I get an error saying that they're not found. I've checked the publish folder, and indeed, they're not there. I call the RDLC files with the following code:
Microsoft.Reporting.WinForms.ReportViewer rvReportViewer;
/* ... */
rvReportViewer.LocalReport.ReportPath = string.Format("Reports/{0}.rdlc", ReportName);
I've tried setting the Build Action on these to "Resource", which is what I have for my static image files, but that doesn't seem to make any difference.
Why don't the reports get copied to the publish directory? Is there a way to force this to happen, or should I be accessing them in some other way?
Thanks!
I don't know if there's special concerns with RDLC files, but here's the general approach for making sure other files get published.
Right click the file in the solution explorer, select Properties. Set the "Build Action" to "Content", and "Copy to output Directory to "Copy if newer".
Go to the project properties->Publish page. Hit "Application Files Button", check "Show all files". Set the "Publish Status" to "Include (auto)"
File Properties
Application Files
I've been using the answer by #nos for a while, but I noticed that in the publication, the set of .rdlc-files is copied to two places:
The original webapplication project relative location;
Inside the bin folder.
So if I had \Reports\Report1.rdlc, I would find in the published location:
1. <published folder>\Reports\Report1.rdlc;
2. <published folder>\bin\Reports\Report1.rdlc.
I don't mean to use copies of the rdlc's in the second location and, indeed, if I delete these, the reports are still generated.
I changed the settings for each rdlc-file to:
Build Action: Content;
Copy to Output Directory: Do not copy.
And now nothing is written to the second location.
Sorry guys this has nothing to do with "Copy Always" or "Copy if Newer". In fact I set it to "Never Copy".
This issue is resolved by changing the Build Action from "Embedded Resource" to "Content". Then when you build and publish RLDC files will get copied to the right place.
instead of using .ReportPath
**used the following code:
reportViewer1.LocalReport.ReportEmbeddedResource="[Project
Name].[FolderName if Exist].[ReportName].rdlc";
Then rebuild your deployment Project.