C# VisualStudio project rebuild giving /platform:anycpu32bitpreferred can only be used with /t:exe, /t:winexe and /t:appcontainerexe - c#-4.0

I have a windows application and using cheetah for config transformations i.e app.config.debug, app.config.test, etc.,
When the project is built in debug mode , it works fine but when teamcity change the mode to test configuration and try to rebuild getting the following error:
/platform:anycpu32bitpreferred can only be used with /t:exe, /t:winexe and /t:appcontainerexe
Can anyone please help me how to fix this?
Thanks

Open the project file with the text editor. Find the line <Prefer32Bit>true</Prefer32Bit> and change the value "true" to "false". There might be more than one depending how many different configurations have been set up.

Removed true from one of the project. It worked.
But not sure how this entry was added to that particular project.

For me the issue was that the project listed in the error had the wrong configuration setup. So while the Configuration Platform for the current build was set to x86, the target platform in the properties for the x86 configuration was set to AnyCPU.
So for OP sounds like the configuration is correct for the Debug build, but your target platform may not match the platform specified in your test configuration profile.
If you experience this issue please check that the target platform in the build properties for your project match the configuration platform.

Related

Publish as Azure Webjob is always forcing to Any CPU when publishing - even when set to x64

For an external library I need to build and run it on x64 configuration.
It seems to do this on every project despite the setting in the publish window. It does seem to honor the Release/Debug setting, but not the Platform setting.
How to proceed?
It seems to do this on every project despite the setting in the
publish window.
The Any CPU won't change because It's a default platform(Like a name), and the any settings actually are changed. That's why your Debug Output always shows "Debug:Any CPU".
This setting could be change,
Build->Configuration Manager->Project Platform->New
After these you go back to your Project Properties ->Build and click Platform x64 will be there. You could also switch them here.
Hope this could help you, if you still have other questions, please let me know.

Azure site dll compatibility issue - System.Web.WebPages.Razor

I'm building a test website in azure, I'm getting an issue in Azure site, Where as my local code published to a folder and setup in IIS is working fine. I work on vs2015. code written in C#. Error is below one. Could not load file or assembly 'System.Web.WebPages.Razor' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. Please help in this. Thanks
cr
Is the dll in your solution set as copy local? (go to references, right mouse button and then properties.)
If not set it to copy local.
Alternatively:
Do you use different versions of the dll in your solution?
Then set a bindingredirect to the latest version and be sure to use the correct one in your application. http://blogs.msdn.com/b/thottams/archive/2007/01/30/introduction-to-versioning-and-bindingredirect.aspx
Adding to what RoteS answered, if you are using MVC on VS2015 and you are deploying to Azure by Continuous Integration, why not reference the MVC Nuget package instead? You won't need to commit or copy that DLL around, and Azure (Kudu) will handle the package restore for you when it's deployed.
Thanks for your replies.
I've tried by two options
1.Setting copylocal = true
2.Instlling Microsoft.AspNet.Mvc -Version 5.2.3
But still the problem was there. It works on Local system when published.
But it was not working in Azure. seemed to be some publish issue.
Finally as 3rd step,
I've taken all the mvc related dlls and copied to Bin mannually, referred from this location instead of the package location.
Set the option - copyLocal = true
It worked fine :)
Thanks.

VS2012 cannot copy DeploymentItem to test output folder

I have a project that is written in MSTest. I have 3 machines that has VS2012 Ultimate Update 4 installed. But with this project, on one of my 3 machines, the DeploymentItem are not copied to the output folder which in turn causes unit test failure. The other two machines are fine with the same project. I am using TFS as source control system. Can someone help me fix this issue?
Update: I have given up, this seems to be an issue of VS2012 installation itself cause the same project can run tests fine on other machines
Do you have a different test project on that machine that points to the same output folder?
According to this thread, one of the projects could fail to output in that case.
It could be that you excluded the extra project on the working machines, or that the order in which the projects are built and deployed is different. Are there any other differences (like number of processor cores) between the machines?
Another cause could be differences in user rights on the different machines (depending on the destination directory you are deploying to). Try starting Visual studio on the failing machine by right-clicking on the icon and choosing run as administrator. Does that make any difference?
Since it is working on your other machines, I guess the copy to output directory properties are already true.
This is a wired one and I encountered a similar issue most recently where the build and output to folder was successful in few machines while it was failing in others. My web project was referencing assemblies from the GAC and a folder located in the relative path inside the solution.
Machines where the output was failing, I was receiving this error in the output something like --> Can't locate or access assemblies in the path..
I resolved the issue by
Removing all the assemblies that were referenced form the relative path
(optional) Manually removed the debug and release folders in both bin and obj folders for all projects. (Probably a clean solution option in the build menu will work as well here, but I avoid taking risk and wanted to be sure)
Added back the assemblies from the local path.
Re-build the project
Run the test project and everything was working fine in all machines.
Hope this helps !!!
It turns out it's my own fault. I didn't set the Test settings in the "Test -> Test Settings" menu. But how could I know? VS2012 on my other machines are all configured automatically. For some reason, that particular machine didn't. So there you have it, the answer to the question. It's a simple one. But when you don't know, it's utterly hard.

Possible to use the Windows Phone 8 Store Test Kit with Custom Build Configurations?

I've got a custom build configuration setup in my V.S. 2012 Win Phone 8 solution (distinct Configurations other than just Debug and Release) and am using SQLite (which cannot be built against the AnyCPU Platform) and cannot find a way to run the test kit since it insists on a "Release + AnyCPU" build. Copying the contents of the actual output folder to "Bin\Release" doesn't seem to satisfy the test kit (nor did setting the output folder in the project file to "Bin\Release" for the appropriate configuration) and I can find no way to change the test kit settings/path. Is this simply impossible or am I just missing something?
I have read this post but it's less than helpful and also incomplete (that post doesn't say anything about custom build configurations). I have also sent negative feedback here asking a similar question (but of course that's unlikely to be replied to).
I was going to add "store-test-kit" and "custom-build-config" tags to this but don't have the reputation to do so so I've added them in this note instead in case it helps with future searches.
My solution combines a number of projects spanning from Windows 8 Desktop to Windows 8 Phone (and including DLLs and other supporting dependecy projects including SQLite). In order to build only what is needed I drastically customized my build configurations. So e.g. I have:
N-Dbg, N-Rls, N-Str and P-DBG, P-Rls, P-Str as build Configurations. These distingush from the Desktop ([N]ot phone) and [P]hone primary projects and the Dbg (debug) Rls (Release) and Str (Store) build sets. I have a distinct Str build so that the live store code bits are excluded from the Release build which also leaves out all the extra Debug features.
As complicated as it all sounds it works really quite well in practice, until I need to build a "Release" version. (And this is completely ignoring the platform part of the equation for which just selecting ARM might suffice, I really can't say because I have no good way to test it at the moment).
Ideally then what I want the Store Test Kit to test against is the P-Str build config. I tried setting the configuration to output that set of files to "Bin\Release" which is where a brand new standard build config puts "Release\Any CPU" builds, but the Store Kit didn't like it. It doesn't even list anything for a path to the XAP file that it's supposed to be testing.
After my initial post I did think to try making a new Release build config that was just setup the same as the P-Str build config but that also did not seem to make the Store Test Kit happy (though I admit that I am not 100% sure that I added the new build configuration completely accurately since it had been a long time since I created the custom config in the first place).
Does anyone out in the S.O. world have any experience with such a completely custom build configuration that might be able to help me out here?
I guess after almost a full year if no one has found a better way I'll take the advice to call this the answer...
I was very close with the idea of copying the files to the Bin\Release location but there were a couple missing pieces. First I had to add a Release+AnyCPU entry to the project file (even though I never actually use it) apparently so that the Store Test Kit knows where to look for the xap. Second, I had to be sure to rename the xap file in the Bin\Release folder to ProjName_Release_AnyCPU.xap. Once these things are done I can run the Test Kit.

code coverage tool from Visual Studio 2012 Team Tools does not work on release bits

When I try to run codecoverage tool on release bits of my website I get an empty .coverage file containing the following error:
Empty results generated: No binaries were instrumented. Make sure the tests ran, required binaries were loaded, had matching symbol files, and were not excluded through custom settings. For more information see http://go.microsoft.com/fwlink/?LinkID=253731
This issue does not occur if I run it on the debug version of the same build.
These are the exact steps I perform:
- start monitoring code coverage on IIS server
codecoverage collect /IIS /session:test /output:test.coverage
- perform a few click around the website
- stop monitoring code coverage
codecoverage shutdown /session:test
Note! I do hae the .pdb files in the same place as the binaries.
Any ideas?
Thanks,
Cristina
I finally managed to get to the bottom of this. For the release build, there were 2 things I needed to change in the .config file
specify the path to the Symbols (apparently this is needed even if the .pdf files are in the same location as the dlls)
I had to remove the default exclusion list since these included Microsoft public key tokens and our product is a Microsoft product.
Hope this will be helpful for others running into the same situation.
Regards,
Cristina
Try this: Enabling Profiling.
[UPDATE 5 Jun 2013 14:04:00-04:00 UTC]
I also found this article that you may be interested in: Application Analytics: What Every Developer Should Know.
As far as Code Coverage is concerned, I didn't see anything specific to using the VS Code Coverage tool and configuring for IIS. I did see lots of articles about testing web applications in general, some of which involved setting up code coverage (Setting Up Machines and Collecting Diagnostic Information Using Test Settings being an example).
Sorry I couldn't be of more help to you.

Resources