Ho to trace dll to some nuget package - nuget-package

I'm working on relatively big solution with many projects in it. Almost each project has dependencies on some nuget packages. In the output folder bit/debug/net6.0 of startup project I have found BouncyCastle.Crypto.dll and I would like to find out where it's comming from.
I have checked all the project files but there is no references to BouncyCastle.Crypto neither any reference in any of .cs files. So it must be a transient dependency.
Question is there easy way to find out nuget package from which this DLL is comming?
Is there is UI for it e.g. in Visual Studio / Resharper or if there is some command for dotnet CLI?

You can use build with --verbosity flag, like this:
dotnet build --verbosity detailed
And then, in output you can grep or search for relevant dll, you'll find something like this:
1:7>Target "_CopyFilesMarkedCopyLocal" in file "/opt/.dotnet/sdk/6.0.403/Microsoft.Common.CurrentVersion.targets" from project "/SOME_PATH/SOME_PATH/SomeProjectName.csproj" (target "CopyFilesToOutputDirectory" depends on it):
Task "Copy"
Copying file from "/SOME_PATH/.nuget/packages/bouncycastle/1.8.9/lib/BouncyCastle.Crypto.dll" to "/SOME_PATH/SOME_PATH/bin/Debug/net6.0/BouncyCastle.Crypto.dll".
Done executing task "Copy".
from project line, will point you to the actual project. Copying file from and to will point to the actual dll.

Related

Compile directory in Azure DevOps Repos and save the results somewhere

Let’s say I have a directory structure like this in an Azure DevOps repo:
Main/
- A/
- *.csproj
- B/
- *.csproj
- C/
- *.csproj
Each subfolder has a .csproj file. I want to compile the Main/A/ folder and save the build results (artifacts?) somewhere, be it a folder or something else. How do I tell Azure to build that precise Main/A/*.csproj file and do I need to use /p:OutputPath inside the VSBuild#1 task, or do I need to use some other Azure task?
How do I tell Azure to build that precise Main/A/*.csproj file and do
I need to use /p:OutputPath inside the VSBuild#1 task
If you're using classic UI, you need to unlink the default solution:
And then choose the A project by the browse option:
If you're using Yaml format, you should use something like solution: A/A.csproj to specify which project to build.
Note:
Since now we're building single project instead of whole solution, we should use Project Configuration instead of Solution Configuration. any cpu is Solution Platform instead of Project Platform(AnyCPU). So we should make sure we're building single project with AnyCPU if we want to build one project with this setting.
If you got error The OutputPath property is not set for project 'A.csproj', that indicates you should use valid project configuration. In your case, if you're using any cpu, change it to AnyCPU.
In addition:
1.To publish the build results as build artifacts for further use. You can use Copy Files task and Publish Build Artifacts task like this:
Copy Files Task.
Publish Build Artifacts
Then you can download the Test.zip in Summary tab from build log page. Also, you can use this artifact in release pipeline by using download artifacts task.
Check this, if you're trying build code project instead of whole solution. You can consider MSBuild Task. They(Msbuild task,VS Build task) both calls msbuild.exe to do the build job.
Hope all above helps :)

Nodejs TFS Build Definition

Can anyone let me know how the build definition for a node.js application should look like? Also how to mention the mocha tests in the Automated tests?
First time when I tried to queue a build, I got an error saying:
Microsoft.NodejsTools.targets not found.
So I went and copied the NodejsTools folder with the .target and dll file in my build server. And I didn't see the error.
Now I get the below error:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets (132): Could not copy the file "obj\Debug\OstNodeJs.exe" because it was not found.
You need the node.js framework and the Visual Studio node.js Tools on you build server, too. You just copied the necessarily files and this may result in other problems.
For the executable copy problem you can try to add <Disable_CopyWebApplication>True</Disable_CopyWebApplication> in the project file. See here: Build on TFS wants to copy a executable from Node.js test project

copy static files to build output folder in gradle

I was using ANT before (Android Project) and i had "static" files in the same packages as my code
Here is an example
src/com/my/app/test/Parser.java
src/com/my/app/test/json_to_parse.json
When executing the unit tests, the json file was copied into the gen folder, therfor it was possible to access the json in the test with
getClass().getResourceAsStream(fileName)
I had to convert the project to gradle, but now the tests are failing.
After checking the "build" folder, i've realised, the .json files are not there, therefor the getResourceAsStream method returns null.
Any idea how to include these "static" files (json, xml, ...) into the build folder?
Moving the files into the resources folder did not work out of the box in Android Studio (even though is should have)
This should be fixed in Android Studio 1.2.
However, this is what i did:
Moved all static files into the resources folder.
In my unit-test module i've added this to the build.gradle file
task copyTestResources(type: Copy) {
from "${projectDir}/src/test/resources"
into "${buildDir}/classes/test"
}
processTestResources.dependsOn copyTestResources
Now, all files located inside src/test/resources will be copied into /classes/test where i can access them with
getClass().getResourceAsStream(fileName)
If i keep the package structure inside the resources folder the same as it was in the java folder, i don't need to adjust any code.
To complete the story a bit more:
JUnit4 runner requires
getClass().getResourceAsStream(name)
while Robolectric requires
getClass().getClassLoader().getResourceAsStream(name)
The files you are asking about are called "resource files" in Maven/Gradle lingo.
Gradle assumes that you are using the Maven Standard Directory Layout.
So, either you move your files into src/test/resources (then Gradle will pick them up automatically), or you tell Gradle that it should look for resources in some other place.
In the latter case, you need to modify the processTestResources task. However, keeping resource files in the same directory as source code is a bad practice. So I advise the former option.
if your problem is happen when you create apk with AndroidStudio.
you can create a jar file that includes your resources with jar.exe
for example i put a.txt into resources directory
and run this code in cmd:
"C:\Program Files\Java\jdk1.7.0_79\bin\jar" cvfe res.jar -c resources
after that a jar file "res.jar" was created
then add that res.jar into libs folder in your project
when your apk is creating resources are added to your final apk and you can use this code to acsess a.txt:
someclass.class.getClassLoader().getResourceAsStream("resources/a.txt");
with this job no need to change Gradle setting.

Can Visual Studio 2012 do a custom build such as: compile project A > compile and link project B > link project A?

I am looking for a way to builds projects in this order with Visual Studio 2012 (C++ but might be a general question):
Compile ProjectA (I just need the .objs)
Compile and link ProjectB
Link ProjectA
I can't simply use a reference/dependency of ProjectA in ProjectB because it will perform the link of ProjectA too early.
I used to do this with VS 2008 this way:
PreBuild Event on ProjectB: vcbuild /pass0 /pass1 ProjectA
Compile and link ProjectB (which is a dependency of ProjectA)
Compile (actually does nothing as it was already built) and link ProjectA
But vcbuild is gone from VS 2012 and I replaced the command with:
msbuild /t:BuildGenerateSources /t:BuildCompile
The problem here is that at the 3rd step where it's supposed to only link (since msbuild already compiled) it now compiles again ProjectA and then links it. Enabling diagnostic verbosity with msbuild showed me this: Forcing rebuild of all source files due to a change in the command line since the last build.. And pretty much no one (including Visual Studio 2010 randomly says the command line changed, and rebuilds) has a solution for this as it's impossible to see what 2 commands are being compared.
The other benefit of doing what I'm looking for directly with Visual Studio (without a prebuild event that launches msbuild in a command line), would be to have compile errors reported to the Errors list and clickable in the Output window.
Maybe under the hood this would use msbuild and Targets specified in vcxprojs but I'd like to know if it's doable at all.
Edit: I have already tried to replace the command calling msbuild by devenv but there is no switch for devenv that can specify compile only (no linking), so it can't be used either.
Edit2: Sound like someone already asked something similar here (no solution) Is it possible for Visual Studio C++ to compile objects without linking
Ok so it can be done by overriding BuildSteps in the .vcxproj and removing the target BuildLink.
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<BuildSteps Condition="'$(BuildSteps)' == '' or '$(SkipLink)'!='false'">
ResolveReferences;
PrepareForBuild;
InitializeBuildStatus;
BuildGenerateSources;
BuildCompile;
<!-- BuildLink; -->
</BuildSteps>
</PropertyGroup>
When VS builds it will not perform the link step.
The original BuildSteps are defined in C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.BuildSteps.target
To finally link the project on the command line later (from a build event on another project for example) we call:
msbuild /t:BuildLink /p:VisualStudioVersion=11.0 /p:Configuration=Debug /p:Platform=x64 /p:SkipLink=false "ProjectA.vcxproj"
Notice that a condition SkipLink has been added to the BuildSteps override so we can specify when to perform the BuildLink and when not to.

CruiseControl.NET: Ignore DB projects in a build

After upgrading to VS2010 we have a few .dbproj files that are causing issues in our CI builds. They do nothing except just store SQL files anyway, so I'd like to just ignore them. I'm running CruiseControl.NET and building my solution with devenv.com. Is there some way for me to tell the build that I want to ignore these projects, or all .dbproj projects?
One way to do it is to create a new solution configuration in Visual Studio. Go to the Debug menu and then Configuration Manager. Create a new configuration and then exclude your .dbproj projects.
Then use that configuration name in the command line of devenv.com instead of 'Debug' or 'Release'
Since its a just a files container project, you could just exclude it from build in Debug and Release
Use msbuild instead of devenv and it will support the 'excluded from build' feature (i think devenv doesn't)
An (somewhat) alternative would be to switch the project into a class library (which will actually will build nothing...)
An example MSBUILD task would be:
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>project_solution_path</workingDirectory>
<projectFile>project_solution_file</projectFile>
<buildArgs>/p:Configuration=Debug /p:VCBuildAdditionalOptions="/useenv" /v:diag /t:rebuild</buildArgs>
<timeout>300</timeout>
</msbuild>
HTH

Resources