Upgrading from VS2010 to VS2013 we started getting this error when running static analysis:
"CA0001 Error Running Code Analysis CA0001 : A class that implements multiple rules must explicitly specify the warning identifier"
I've spent a few hours researching but haven't found anything about what this error means or how to fix it.
The CA0001 is just a generic error that FxCop doesn't like the rule, but what is a "warning identifier"? And why is this an issue with VS2013 but not VS2010?
I found that if I move the FxCop (Code Analysis) .targets reference BEFORE the Microsoft.CSharp.targets one that solves the problem for me.
And while we are on the topic, apparently the StyleCop .targets file needs to be loaded AFTER Microsoft.CSharp.targets for the StyleCop rules to be run at build time.
Example:
<Import Project="$(SolutionDir)\..\msbuild\CodeAnalysis\Microsoft.CodeAnalysis.Targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\..\msbuild\StyleCop v4.7\StyleCop.targets" />
Related
I am trying to setup a xamarin android project using f# with Visual Studio 2019, but I can't seem to get to the point where "Hello world!" would show on my device!
The template project build succeeds, and my device is successfully connected. However, attempting to deploy the project fails with error telling me the reference to the FSharp.Core could not be resolved. If there is anyone who knows more about this issue, or can speculate to what is going on and what might be done to solve it, any help would be much appreciated.
Upon creating a blank android application I stumbled on the error explained in this thread:
Xamarin.Android.FSharp.ResourceProvider seemed to be missing, and the FSharp.Core not referenced. I solved this problem by installing both via Nuget. However, looking at my intellisense and console errors, the FSharp.Core was still not properly loaded.
After reading this article, I managed to make intellisense happy and the build succeed by editing the fsproj files reference to the FSharp.Core from "Include" to "Update".
<PackageReference Update="FSharp.Core" Version="4.7.0" />
However, this time I get a reference error when attempting to deploy the project to my android device.
XA2002: Can not resolve reference: `FSharp.Core`, referenced by `Xamarin.Android.FSharp.ResourceProvider.Runtime`. Please add a NuGet package or assembly reference for `FSharp.Core`, or remove the reference to `Xamarin.Android.FSharp.ResourceProvider.Runtime`.
XA2002: Can not resolve reference: `FSharp.Core`, referenced by `Playground`. Please add a NuGet package or assembly reference for `FSharp.Core`, or remove the reference to `Playground`.
(Playground is the projects name)
I am deploying to a relatively old device (android 4.3, api level 18), but looking at the errors it does not seem related to the failure. I must be missing something simple like a build or reference setting.
I managed to make intellisense happy and the build succeed by editing the fsproj files reference to the FSharp.Core from "Include" to "Update".
No, you should adding instead of editing, like this:
<PackageReference Include="FSharp.Core" Version="4.7.0" />
<PackageReference Update="FSharp.Core" Version="4.7.0" />
This is a workaround for VSMac bug https://github.com/mono/monodevelop/pull/5137
I have a Visual Studio 2010 C++ solution with two projects: an executable and a library. I am successfully able to delete project configurations from Configuration Manager for one of the projects (executable), but not the other (library).
Both projects were previously part of a vs2008 solution that have since been upgraded to vs2010.
When I try to delete a configuration from the library project, I get the error:
The operation could not be completed. Invalid pointer.
This happens for all configurations for that project.
Since this happens with only one of the projects, it leads me to believe that there is probably something wrong with the project and that's why VS2010 doesn't like it. Any ideas what may be wrong?
After some trial and error, I found that the problem was with some left-over project configuration in the library project file (library.vcxproj). The offending section was:
<ProjectExtensions>
<VisualStudio>
<UserProperties RESOURCE_FILE="library.rc" />
</VisualStudio>
</ProjectExtensions>
After deleting the section above from the project file and reloading the solution, I was able to delete project configurations.
I'm trying to create a deployable package from a web api project, and I'm getting the error
error MSB4057: The target "Package" does not exist in the project.
When I try to build a web application running MVC5, I have no issue.
The command to build the MVC5 application is
MSBuild.exe Project.Web.csproj /P:Configuration=Debug /T:Package
The command for the failing web api application is
MSBuild.exe Project.Api.csproj /P:Configuration=Debug /T:Package
I'm assuming that perhaps I need to install something, but I have no idea what. Can anyone tell what I'm doing wrong?
Note: If you need more information let me know.
I read around and saw that I might have to add the property VisualStudioVersion, but whenever I tried it the package still failed.
I was just comparing the csproj files and noticed that the following property group was missing:
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
Adding this fixes it, so maybe I need both the VisualStudioVersion and VSToolsPath.
After that I quickly ran into deployment issues, which in turn were related to more config differences. This time it was the top-most node Project. The attribute ToolsVersion was set to 4.0 in one project, and 12.0 in the other. Setting them both to 4.0 fixed it, probably because I was compiling with MSBuild 4? I'm not going to lie, it was mostly trial-and-error for a few days to figure this out. God I hope I never have to touch this code again...
The Generate Serialization Assemblies option in Visual Studio creates a MyAssembly.XmlSerializers.dll when my project is built. This question (https://stackoverflow.com/questions/934411/what-is-myassembly-xmlserializers-dll-generated-for) indicates a reason why it's there in the first place, and some of the answers provide ways to turn it off, but my question is why would you choose to turn it off? Does having it turned on cause problems in certain situations (and, if so, what are those situations)?
Only problems you might be facing are with build tools - such as msbuild, because if you use sgen from x32 SDK on assembly that is explicitly x64 it will raise a build-time error (you can easily overcome this by setting correct SGenToolPath path to msbuild or target MSIL instead). IMHO it is better to deal with build time issues and have quicker startup time.
Turning it off stopped the build and run time errors I was getting as a result of upgrading my application to v4.0. I was getting SGEN errors after trying many of the solutions posted online. Doing this solved that issue.
I had to turn it off when I needed to Sign a "ClickOnce" application. I could not successfully deploy it with the Generate Serialization Assemblies on. The MyAssembly.XmlSerializers.dll had reference in the manifest file, but it is was not part of the deployment package.
Right click your project and select Edit.
Next add this inside "Release" property group
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<GenerateSerializationAssemblies>off</GenerateSerializationAssemblies>
</PropertyGroup>
I have a project which uses a system to authorise users. While I make some updates I want to to be able to set IsAdmin(username) to always return true. I wont forget to remove this, however it would be helpful if there was functionality in visual studio, like the //TODO, which created a warning or on build or publishing. Does anyone know of any functionality like this?
Thanks
Your C# and VB (and C++ in VS 2010) project files are MsBuild files and are built using the MsBuild engine. You could edit your project file in a text editor and add a warning that is conditional on a property being set.
<!-- These two targets exist at the bottom of all .csproj/.vbproj files,
but are usually empty. -->
<Target Name="BeforeBuild">
<Warning
Text="This is a debug build!."
Condition="'$(Configuration)' == 'Debug'" />
</Target>
<Target Name="AfterBuild">
</Target>
You could also make it an error which stops the build using the Error task.
I'm not sure I grasp what you want to do, but you'll probably have to use preprocessor directives (such as #warning), and maybe combine them? Something like
#if DEBUG
#warning This is debug!
#endif