<p>Does anyone have any experience getting MSTest to copy hibernate.cfg.xml properly to the output directory?  All my MSTests fail with a cannot find hibernate.cfg.xml error (I have it set to Copy Always), but my MBUnit tests pass.</p>

[{'answer_id': 20178, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 5, 'selected': True, 'text': '<p>You can try adding the DeploymentItemAttribute to one of your tests, or edit your .testrunconfig file and add the file to the Deployment list.</p>\n'}, {'answer_id': 177734, 'author': 'Amir Arad', 'author_id': 11813, 'author_profile': 'https://Stackoverflow.com/users/11813', 'pm_score': 1, 'selected': False, 'text': '<p>a workaround rather than an answer: NHibernate supports <a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/session-configuration.html#configuration-programmatic" rel="nofollow noreferrer">programmatic configuration</a>. so you can write your own native properties/config file and parse it into hibernate configurations on startup.</p>\n'}, {'answer_id': 178478, 'author': 'Watson', 'author_id': 25807, 'author_profile': 'https://Stackoverflow.com/users/25807', 'pm_score': 2, 'selected': False, 'text': '<p>Ran into the same thing a few weeks ago -- this is actually a <a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=299578" rel="nofollow noreferrer">bug with MSTest</a> -- I believe this was corrected with the recent <a href="http://msdn.microsoft.com/en-us/vstudio/products/cc533447.aspx" rel="nofollow noreferrer">Service Pack Release</a> (even though it still says "Active").  If not, all I had to do was reference my hibernate.cfg.xml directly (sloppy but works for testing -- this is referencing the hibernate.cfg.xml file in my tests project from the "TestResults" folder):</p>\n\n<pre><code> try\n           {\n                sessionFactory = new Configuration()\n                    .Configure()\n                    .BuildSessionFactory();\n            }\n            // Assume we are in "MSTest mode"\n            catch (Exception)\n            {\n                sessionFactory = new Configuration()\n                    .Configure(@"..\\..\\..\\Program.Tests\\" + @"\\hibernate.cfg.xml")\n                    .BuildSessionFactory();\n            }\n</code></pre>\n'}, {'answer_id': 178651, 'author': 'yfeldblum', 'author_id': 12349, 'author_profile': 'https://Stackoverflow.com/users/12349', 'pm_score': 1, 'selected': False, 'text': '<p>I like to mark my NHibernate config files as Embedded Resources, and use the Configuration.Configure() overload which reads config files from the Assembly Resources.</p>\n'}, {'answer_id': 280621, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>Edit localtestrun.testrunconfig (in your solution items folder). Select the deployment option and add the hibernate.cfg.xml file to the list of additional files to deploy. The file should then get copied to the output directory where the test gets run.</p>\n'}]
['https://Stackoverflow.com/questions/20173', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1975/']