Loading localized resx files during TFS test runs - asp.net-mvc-3

We are using .resx files for internationalizing our app. Our solution and tests (mstest) works perfectly localy, and when deployed, however when we try to run the tests from Team Foundation Server (TFS) it seems the resource files are not found (all strings are always returned in en-US).
For each resource file, we have selected:
"Embedded Resource" for the Build Action
"Copy if newer" for the Copy to Output...
"PublicResXFileCodeGenerator" for the Custom tool
Any suggestions on what we could do to fix this?

Build Action = "Content"
Copy to output directory = "Copy always"
Please make above changes.

Related

Including additional files when publishing an app with Visual Studio 2012

I have a console application that I've been developing and I'm just about ready to publish it for consumption.
However, there's a file that the app needs to reference (a couple files actually) and I'd like to try to include these either during install logic or via an outside process. Here's the situation:
The application fires off a load test based on some criteria the user chooses. The load test is defined by a .loadtest file which is created outside of this project.
So what I would like for the installer to do is contain the .loadtest files and just shove them in a default directory that the project can reference.
I can't figure out how to add this specific file as a pre-requisite or anything though, in the publish wizard. Any ideas?
When you add a file to the solution, it does not automatically get attached as part of the build in some cases. If you right click the file in your solution explorer and select "Properties", change the build action to "Content". This will ensure that VS includes the file as part of the build/publish and places it in the output directory of the build process.

Edit ASP.NET MVC 3 resx files in deployment server without recompiling

This is my first question here!
I have one ASP.NET MVC 3 Project with a Properties folder, containing some .resx files used to difference content in my views by language (en/es).
I'm working in VS2010 with .Net 4.
When I deploy the application to server, I find that no resx files are published, and instead of it, I have some .dll files.
I have set the build action to Embedded resource , Do not copy to output directory and PublicResXFileCodeGenerator as Custom Tool in .resx files properties.
I want to have .resx files on the server and be able to edit them without recompile or redeploy. The views should use those changes.
How can I do that?
Thanks for your help!!
Put the resx files in your App_GlobalResources and change the "Build Action" to Content and "Copy To Output Directory" to false.
Make sure the "Custom Tool" is set to GlobalResourceProxyGenerator
That should make them changeable even at runtime.
You can simply use xpath to query over them, take the keys, values and comments and edit them as you wish using an XDocument.
You should also know that such a thing won't work with visual studio's publish because App_GlobalResources is not allowed with precompiled website.

ASP.NET MVC Web publishing does not copy excel file

My project has Help folder which is located within web project AND in which we kept some template excel files.
When we do "Web Publishing", these files does not get copied on the server. If we change the extension to xml from xslx then they get copied.
Can you please suggest something to change the publishing scheme/method?
Have a nice weekend!!!
Set the "Copy to Output Directory" flag in the File Properties
Select the file in Solution Explorer, and in the properties window change Build Action to Content.
For more background information on how files are selected for publishing, see
http://msdn.microsoft.com/en-us/library/ee942158.aspx#why_dont_all_files_get_deployed

What causes a duplicate web.config under the obj output folder after publishing an MVC3 app?

Often after publishing my MVC3 app, using a file system publish, when I next try to run the app in the VS2010 debugger, I get the error: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. I get this because my web.config file has been duplicated in a folder called obj\debugrelease\package\packagetmp\web.config, where debugrelease is the name of the build config I am publishing to. Simply deleting the whole obj folder solves this issue, but I'm annoyed that it happens and can't help wondering what is wrong.
Have you tried the following?:
Looking at project properties >> Package/Publish Web tab to see if there is anything not set quite right, for instance I have "Deploy only files needed to run this application".
Showing all files in your project to make sure you haven't got web.config files hiding somewhere other than your obj folder.
Opening your project file in a text editor to see if the config is referencing a web.config file somewhere it shouldn't?

How to make the Visual Studio compiler ignore a file?

Is anyone aware of a way to make visual studio completely ignore a file when compiling? I have a C# solution that has a foo.config file that isn't really a standard config file - it's just a text file. During compiling VS grabs a hold of the file and bombs.
I'd like for it to act as though it's just a text file. I do not have the option of changing the name of the file.
EDIT: Please note that BuildAction does not exclude files from the compiler checking them. It simply decides if the file is compiled into the assembly, whether it's content (like a jpg or something), or whether it is a resource file. For more info: see the MSDN page.
EDIT2: Apparently, if you have a text file that is named foo.config and you have it open while building, VS2005 will pop up an error thinking that the file should be xml. However, if you close the file, VS2005 will ignore it.
Solution: Visual Studio validation causes errors if you have a non-compliant file open during build time. For an example of how to turn this off (for HTML), see Scott Guthrie's post. As Allen mentioned, you should also have the Build Action turned to "None". Unfortunately, this will not stop build errors if you have the file open.
right click > properties
Build Action: set to "None"
Edit: If you're talking about app.config, you really cant mess with the format of that, you need to put it in a different .config file.
I just double checked, VS.net doesnt care as long as its not app.config or web.config and the config file build action is set to "None", it will "error" if you have the file open but it will not cause the build to fail or keep it from building the assemblies.
Close the file and the errors will go away, similar to the errors you get about HTML markup. The displaying of these "errors" is probably a configurable setting in vs.net
The action to take depends on the solution and and file type. For instance (in VS2005), in a C++ solution I can right click on the source file name in the solution explorer and view its properties. The first "General" option is "Excluded From Build", which will allow you to exclude the file from the build process without having it excluded from the project altogether.
I pulled up a .config file in a C# solution, and found a "Build Action" option under the Advanced section. That should probably be set to "None".
Just right click on the file and choose "Exclude from project".
If you still want to see it in your project, select the project and click the "Show all files" button at the top of the solution explorer. This will show all the files in the directory tree even if they aren't actually part of the project.
Are you sure that VS compiling .config file???
You should check it's Build Action in file options and may be set it to none.

Resources