Deploying a Content File *Link* for a VS2008 Website project - visual-studio

I have added an Xml configuration file to a web project in VS2008 using the “Add as Link” option on the “Add Existing Item” dialog. The Xml file is common to a number of other web projects within the solution so it exists in the Solution level directory. I have used the file link functionality to avoid a unique copy being added to each web project.
SolutionFolder
SharedConfigSettings.config
WebProject1Folder
WebProject2Folder
Problem
The problem is that the linked file is not deployed. I need the file to be copied to the root of the web application so that it is in the same location as the web.config file.
I have tried
1) Setting the file properties on the link as...
Build Action: Content
Copy to Output Directory: Do not copy
...results in the file not being copied at all
2) Setting the file properties on the link as...
Build Action: Content
Copy to Output Directory: Copy always
...results in the file being copied to the Bin directory below the web application root.
3) Post build event to copy the file. This works but is messy to implement because it requires additional steps to get this to work on the build server.
Is there a way that this can be done using the standard options available in the project file?

Related

Public MVC project using MSBuild not copying the global.asax file and i am getting error 404

When i am using the "Publish" button directly from the Visual Studio environment everything is working great. but when i am trying to publish using MSBuild command line, the global.asax file omitted and i am getting 404 Error when trying to access the site.
I suspect, but not sure, that when i am using MSBuild it uses the "precompiled" setting and i see the files App_global.asax.compiled file inside the BIN directory but the IIS ignores it.
if i have the file App_global.asax.compiled on the bin folder, is that mean that i don't need the global.asax file in the root directory? Why the IIS ignore the App_global.asax.compiled file and not loading the application?
Right click on the Global.asax file and check Build Action in properties window. Ensure it is set to Content

How do I access a resource file in Xcode?

To access the resource file namefile from a program:
I ostensibly just need to check the box "target membership" to identify it as a resource file:
but this box is disabled.
What am I missing?
The helloworld target in your project is configured as a command-line tool (the square black icon that looks like a Terminal indicates this). Those compile to a single, standalone file thus Xcode cannot embed a resource file with it (which is why it's disabled).
You need to build a "Cocoa Application" target if you want to be able to include resource files. You can start a new project using the Cocoa Application template or manually add a target to your current project. You'll probably find it easier to start with a new project.
Add resource files to a command line tool
Add the file to the "Copy Files" section of your project's Build Phases:
Make sure to set Destination to "Resources", clear Subpath, and untick Copy only when installing.
Then whenever you build, Xcode will copy the file into your app's build directory, right next to the executable:
That's a screenshot of the ~/Library/Developer/Xcode/DerivedData/[your project]/Build/Products/Debug folder.
This method also works when you archive your app.
Note: if you want the file to be in some subfolder relative to the executable, e.g. res/images/, set the Subpath to that path.

How to have msbuild copy files to output directory across references?

Suppose we have a project A with output directory bin/ and a project B with output directory test/bin/. Project A needs to have a certain configuration file copied to its output directory. Currently, this is being done by adding a pre-build event that looks like
COPY /Y "$(ProjectDir)..\config.ini" "$(TargetDir)"
Project B has A as dependency. When project B builds, the binary resulting from A is correctly copied to the output directory of B, but the config file isn't!
How can we achieve that all files that A needs to have are also copied to the output directory of B?
What you want is a Link File. I've used these before to ensure that connection.config files are copied to multiple projects.
I created a sample solution that mimics your described scenario as seen below. The ConsoleApplication1 references the ClassLibrary1 project. In the solution, I created a solution folder config and added the shared config that needs to be copied.
In order to have a single file that is copied across multiple projects, you must create a single file, and then add it as a link to the projects that need it. This can be done by right clicking on the project, and choosing Add -> Existing Item.... You will see a dialog as show below and you want to choose the Add as Link option from the dropdown instead of just Add.
Finally, edit the properties for the linked file to copy it to the output directory.

Including a batch file with VSIX

I'm trying to create a Visual Studio plugin, it's a menu item that executes batch files. I have no idea how to include the batch files (or any other additional files) with the VSIX when publishing so that they are available to all users that install the extension.
In solution explorer right click on the batch file (in this case I called it BatchFile.cmd) and choose 'Properties'
In the properties window change:
Build Action: Content
Include in VSIX: True
When the solution is built in release mode it creates a VSIX file in the bin/Release folder. This is the package and it contains all the assets required. When the package is installed on another machine, the batch file is included in the install location and can be referenced using:
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "BatchFile.cmd"
You can just include the batch file as content in your project, and use GetAssembly() to find the location of your adin dll at runtime

How to automatically copy files in building project with Visual Studio

I have some custom made XML files and a read me file that I've included in my project.
How do I make it so that these files are copied to my debug/release folders automatically when I build my project? I've tried setting the Copy to Output Directory property to "Copy Always" but this doesn't seem to do the trick.
I'm using VS2010
I've found the answer. The build action needs to be set to Content if you want to just directly copy the file to the output folder.

Resources