I have been digging but cannot find the answer - I THOUGHT I had found it in this question but it is not working on my system. The only difference that I can see is that I am giving msbuild a solution file and not an individual project file - must I do it at the project level to get output? The command line I entered was:
msbuild Interlink.NET.sln /p:RunCodeAnalysis=true /p:CodeAnalysisLogFile=test.xml
Obviously, test.xml was not created or I would not be asking this question...
The solution is a C# project in VS2015, in case any of that effects things. In Visual Studio, I can select "Analyze | Run Code Analysis on Solution" and things work as expected. I want to incorporate the analysis into an automated build process and produce an XML file with the analysis.
Well yes the command that you used is correct and will work for .sln files.
Only a test.xml file will be created inside each of the constituent projects.
And these copies will contain the static code analysis reports of that specific prject.
It will not be created at the level of the .sln file.
I ran msbuild with the following arguments and the xml file got produced in the output directory, but the filename I've given got ignored. It was named vc.nativecodeanalysis.all.xml instead.
msbuild Project.sln /p:Configuration=Release /p:Platform=x64 /p:RunCodeAnalysis=true /p:CodeAnalysisLogFile=test.xml /t:Clean;Rebuild
Project.sln is a C++ project in VS2017 though.
Please refer to the below forum
https://stackoverflow.com/questions/30472569/how-to-get-an-xml-report-out-of-msbuild-code-analysis
msbuild MyProject.csproj /p:RunCodeAnalysis=true /p:CodeAnalysisLogFile=MyXmlReport.xml
Related
In the older version of the visual studio, it was possible to build a small "Hello World" application that has a single .exe file and size around 200KB. I started to use a new version of Visual Studio and I have with this simple task.
When I build it with parameters:
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>
The output is single .exe, but with the size around 25MB. When I build it as "Framework dependent", the .exe is around 150KB, but it has additional 2 .json configuration files.
Is it possible now to publish a single small .exe file without the .json configuration files in Visual Studio?
You can try to use Costura.Fody to make a single exe without another file.
The following link is a similar question, you can refer to it to solve this problem.
How to make a Single exe file from c# assembly and dll?
I am trying to create multi file assembly by creating .netmodules for respective Visual Studio projects. These .netmodules are being created successfully. Command used to produce the modules:
csc.exe "/out:$(ProjectDir)$(ProjectName).netmodule" "/t:module" "/recurse:$(ProjectDir)*.cs"
The problem with the above command is the switch :/recurse:$(ProjectDir)*.cs, which compiles all files in the project including AssemblyInfo.cs file. This file is compiled for each project.
At the end when I am trying to build a multi file assembly using following command:
csc.exe /t:library /out:MultiFile.dll /addmodule:Foo.netmodule /addmodule:Boo.netmodule
I get the error error CS7061: Duplicate 'GuidAttribute' attribute in 'Foo.netmodule'
Please state any ways to create multi file assembly.
As of me, I can think of two ways, deleting the AssemblyInfo.cs files from project or find a way to exclude the specific files from compiling in the /recurse switch (don't know how to exclude the file).
Although it would be nice to pass some parameter to CSC.exe to exclude some files from /recurse switch. I did not find it anywhere.
Solution I opted for:
Copy all source files for each Visual Studio project to different folder, excluding the AssemblyInfo.cs file.
Compile all the files from that folder to produce .netmodule.
I am trying to get sharpdevelop to generate a .cs file from my .xsd. I've tried adding an entry to the solution's "Pre-build event command line" but it has no effect, not even output. So I tried adding a simple
echo "Hello World!!!"
to the pre-build just to make sure it was working. That had no effect either, suggesting that pre-build events aren't being invoked.
I also tried to assign my .xsd file a "Custom Tool" in its properties. This caused a "Cannot find custom tool" error, no matter what I put in the Custom Tool property.
Here is how I used xsd.exe to generate a C# file using a pre-build event in SharpDevelop 4.4.
Make sure xsd.exe is on your path. If this is configured you should be able to run xsd.exe from the command line without having to specify its full path.
With your project open in SharpDevelop, from the Project menu select Project Options. Then select the Build Events tab.
In the Pre-build event command line text box add the following:
xsd $(ProjectDir)myschema.xsd /c /out:$(ProjectDir)
This assumes you have an XML schema called myschema.xsd in your project directory.
Now build the project.
Building the project will run xsd before the rest of the project is compiled and generate a C# file in the project directory. Once this file is generated you can add the C# file to your project and write code that uses the classes in this file. So you can modify the schema and a new C# file will be generated with the changes.
In order to see echo statements in a pre-build event you need to increase the MSBuild logging level. By default SharpDevelop shows minimal output from MSBuild.
To see the echo statements, from the Tools menu select Options. In the General category select Projects and Solutions. Then change the Build verbosity to Diagnostic in the drop down list. Then when you build with SharpDevelop you will see a lot of MSBuild output, but if you search for your text you will find it in the output:
Target "PreBuildEvent" in file "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets":
Using "Exec" task from assembly "Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "Exec"
echo 'Hello world'
'Hello world'
Done executing task "Exec".
I am new to Apache Qpid, Cmake and Python. I have successfully built Qpid on Debian and ran some of the tests. I am now trying to build Qpid on Windows so that I can write a C# client, but something seems wrong. When I run the cmake command it ends up giving me to following output:
Please wait while cmake processes CMakeLists.txt files....
C:/Program Files (x86)/Python330/python.exe: can't open file 'setup.py': [Errno 2] No such file or directory
Variable Name: BUILD_ACL
Description: Build ACL enforcement broker plugin
Current Value: ON
New Value (Enter to keep current value):
I am trying to understand when setup.py should have been generated/downloaded. I can't find it and I can't find any documentation that describes when it should have been generated or installed. Also, somewhat off-topic, why did the cmake process start prompting me for BUILD_ACL and other configs?
I have ran cmake for both VS 2008 and 2010, using the following commands, and both yield the same output:
cmake -i -G "Visual Studio 9 2008" .
cmake -i -G "Visual Studio 2010" .
I am using the following file from Apache to build Qpid:
qpid-cpp-0.18.tar.gz
As you can tell from the log statements above I am using Python 3.3.0.
I understand that the setup.py is a file used by Python for installing components. It appears that the cmake script is attempting to install something in the tests directory based on part of the cmake script I found by searching for setup.py. I would think this is something that would either be supplied in the Qpid tarball or somehow generated as part of this cmake process.
All that said, I ended up holding down the enter key accepting all the defaults of cmake and it generated the solution file and project files. I am able to open the resulting Qpid solution in VS2008 and build some of the projects. So, that raises the question, why was the setup.py needed?
Qpid user questions get good responses when asked at users#qpid.apache.org
The qpid developers are fairly responsive to the mailing list.
cmake -i does an interactive configuration. That's why it asks for all the variable values. cmake without the -i goes with the defaults. It is possible to answer "y" to variables that should be 'n' for your system, producing a build environment that won't work. Try without the -i to get things started.
Running cmake twice in the same directory with two different generators is generally a bad practice. In your case it will generate a .sln file and .vcproj files for VS2008, and it will generate a .sln file and .vcxproj files for VS2010. If you do in-source builds the files may look the same but they are not. After you've run both cmake commands then the files will continue to look the same.
Unpack the source tarball again and try cmake using an out-of-source build.
mkdir b32-vs2010
cd b32-vs2010
cmake -G "Visual Studio 2010" ..\qpidc-0.18
Directory b32-vs2010 will have your 2010 solution and project files, and all the generated source files. It leaves the source directory clean and free of generated files.
This should run without a complaint about setup.py. If you continue to have trouble please take advantage of the users mailing list.
I have a solution with many projects. There is actually a Core project and a few plugins. I changed OutputPath for all plugins so all binaries end up in the Core bin\debug folder. (this is necessary as the Core do not have a reference on plugins, hence it does not "include" plugins binaries when it is compiled.)
So basically my folder structure is as follow:
Solution
MySolution.sln
Plugin1\
Plugin2\
Core\bin\debug
Each plugin OutputPath is "..\Core\bin\debug". When I open the solution Visual Studio creates a folder "Core\bin\debug" in Solution's folder parent as if the relative path starts from .sln file. However when I build the solution the binaries are output to the correct path ("Solution\Core\bin\debug").
Core\bin\debug
It looks like a Visual Studio bug to me, but maybe I overlooked some option somewhere. Any ideas how to resolve this problem ?
PS: I know this not a critical issue as everything build and works fine, however I dislike the idea of meaningless folder hanging around
Rather than changing the output location of the plug-ins, what you could do is create a post-build script (Properties \ Build Events tab) for them that will copy the them to the Core folder. That would prevent the confusion with output folders.
This command line should do the trick for you:
copy "$(TargetPath)" "$(SolutionDir)Core\$(OutDir)"
If you need to copy .pdb and .config files as well, you can add more lines:
copy "$(TargetPath).pdb" "$(SolutionDir)Core\$(OutDir)"
copy "$(TargetPath).config" "$(SolutionDir)Core\$(OutDir)"
If you really want to do it with a single line, this should also work, though it's not as clean:
copy "$(TargetPath)*" "$(SolutionDir)Core\$(OutDir)"
If you're not using the same output path in both the main project and the add-ons, you'll need to replace $(OutDir) with a hard-coded value. If you have them set to target the typical "\bin\Debug" folder (or have just left the defaults in place), then you can get away with using the $(OutDir) value.
Instead of using "..\Core\bin\debug", use "$(SolutionDir)\Core\bin\debug".