I have an XML file in ChildProject with Build Action set to Content and Copy to Output Directory set to Copy Always. When there are no changes and I then go in and edit the XML file, save, and then build the PrimaryProject (Console Application) the XML file that is built does not contain the change.
A workaround is including the XML file as a link in the PrimaryProject but this does not seem expected behavior? It seems that a change to only a content item does not trigger a build of the ChildProject.
Note that in Configuration Manager all projects are checked to build and the normaly build process works as expected. Currently using VS 2013 Professional.
Related
I'm trying to create a WPF application to do some of the time consuming QA tasks easier. Now I ran into problem of creating a file that would be used for configuration of some operation via ssh. This file will contain default configuration, however it might be updated by the user with new values.
I changed the properties of a file to "Build Action - Content" and "Copy to Output Directory - Always" however when I publish and install the application the file is not in the directory.
How can I make the file appear in the output directory and be available for some changes?
The published files get a .deploy extension by default. This is a setting that can be changed under Project->Publish->Options->Deployment in Visual Studio.
If you uncheck the Use ".deploy" file extension option and re-publish, you should see and be able to use the content file in the Application Files/app directory of the output folder.
I have a c# project which I added a xml-file (Add -> New -> xml).
The property of the file for Copy to Output Directory is set to Copy if newer and in the project properties for Publish -> Application Files -> Publish Status is set to Include.
When I debug my project I read and write that xml-file and it is correct updating in the bin/Debug folder but not in the main folder of the solution. So the xml-file in the solution is not updated, only the xml-file in the Debug folder.
I know from other projects that I get a hint when I stop debugging after a xml-file was modified that the xml-file was updated and if I want to reload it. That hint I don't get so something must be wrong with the link to that file.
If you want to rewrite the XML file that is part of your project, you have to write to that XML file - not to the copy in your bin\debug folder. This is not generally what most people want. If the file is part of your project, most people would consider that a source file that you would want to keep in its original condition, not a file that you want to edit while debugging.
If that is what you want to accomplish, make sure you read and write to ..\..\MyFile.xml relative to your executable. That's assuming the XML file is in the root folder of your project, and that your project isn't configured to use any non-standard folder structure.
I have a c# service that when built creates a .msi file in the debug folder. At the minute I have to manually copy the .msi out of the debug folder and place it into an install folder in another project in the same source so that tfs will identify the change and allow a check-in.
Is there anyway to set up the project so that the installer gets placed into a different directory when built for check-in?
How about adding a post build event to your project.
http://msdn.microsoft.com/en-us/library/ke5z92ks%28v=vs.110%29.aspx
You could either call a batch file, which has the commands you need, or add the commands to the post build event command line text box.
Copy file(s) from one project to another using post build event...VS2010
if everyone is working with the same workspace mappings, ie, the folder you want to output to is in the same relative path for all developers you can just change the build output location.
obviously you need to do this for each configuration or set the same for all configurations.
I have a t4 template, that loops over an xml file in the project and genrate the code.
Is it possible to make the T4 to run when a certain file has bee saved, or when I build the project?
VS 2010
Thanks
Add the XML file to your project
Right Mouse button on your xml file in your project solution explorer and view properties
Excluded from Build should say No
Item Type should say Custom Build Tool
Setup Custom Build Tool Command line and Outputs.
Now whenever the xml file changes (ie newer that its output) it will trigger a build. Rebuilding the project will also trigger a build.
Dynamo.AutoTT will do what you need. You can configure it to watch files via a regex, and specify which T4 templates you want it to trigger.
You can download it from here : https://github.com/MartinF/Dynamo.AutoTT
Just build it, copy the dll and AddIn files into
C:\Users\\Documents\Visual Studio 2012\Addins\
and away you go.
If you want to get it going in VS2012 you will need to modify the a Dynamo.AutoTT.AddIn file and set the Version to 11.0 inside the AddIn file;
I have a solution in Visual Studio Express that looks like this:
The LogicSchema class in C# that will parse a specified XML file at run-time. The following is in the main method of Program.cs:
LogicSchema ls = new LogicSchema(
XDocument.Load(
"schemas\\C#Schema.xml",
LoadOptions.PreserveWhitespace));
I created a folder in my solution called "schemas" to save the XML file and set the Build Action to Content and the "Copy to Output Directory" value to be Copy if newer.
My expectation is that if open the file in notepad, make a change, and save it, the updated version of the XML file will be copied to the ouput directory (in this case, bin\debug) when I press F5. However, the updated file is not copied to the output directory unless I select Rebuild. Regular Build does not work.
What do I need to change so that when I press F5, the file is copied to the output directory when it's been updated?
It seems to work also in Visual Studio 2008 Team System -
must be Expression edition specific, so cannot repro...
OK, my original guess was not true - it is about XML file being in the referenced library. Can repro it now.
I think the most natural way would be to embed the XML as resource and then read it with GetManifestResourceStream(). This way, the XML file would follow your dll as you reference it without copying it separately even if you reference the dll directly and not through project reference.
...or then you could use Pre-build event? (Project properties - Build Events):
copy $(ProjectDir)test.xml $(SolutiontDir)projectFolder\bin\debug\test.xml
I would think it will always run even if VS thinks no source files have changed. At least in full VS2008 this is the case - just tested.