MSBuild not creating DLL's in Bin directory - unit-testing

We are using ADO 2019 on premises and we have a build server where we build everything. I have an ASPNet web page that the developer has add a second project to the SLN for testing.
I am getting the following errors
XYZ.Tests\Properties\PexAssemblyInfo.cs(15,12): Error CS0246: The type or namespace name 'PexAssemblySettingsAttribute' could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(15,12): Error CS0246: The type or namespace name 'PexAssemblySettings' could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(18,12): Error CS0246: The type or namespace name 'PexAssemblyUnderTestAttribute' could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(18,12): Error CS0246: The type or namespace name 'PexAssemblyUnderTest' could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(19,12): Error CS0246: The type or namespace name 'PexInstrumentAssemblyAttribute' could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(19,12): Error CS0246: The type or namespace name 'PexInstrumentAssembly' could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(20,12): Error CS0246: The type or namespace name 'PexInstrumentAssemblyAttribute' could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(20,12): Error CS0246: The type or namespace name 'PexInstrumentAssembly' could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(21,12): Error CS0246: The type or namespace name 'PexInstrumentAssemblyAttribute' could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(21,12): Error CS0246: The type or namespace name 'PexInstrumentAssembly' could not be found (are you missing a using directive or an assembly reference?)
The main Project has the Dll's needed in the Bin Directory, but the second project has no files in the Bin directory.
My MSBuild Arguments are as follows
/p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:PrecompileBeforePublish=true
/p:DeployDefaultTarget=WebPublish
/p:publishUrl="$(build.artifactstagingdirectory)\$(BuildConfiguration)\wwwroot"
/p:OutDir="\Bin\$(BuildConfiguration)"
I have tried to pre-Build the test application using the .csproj, but since it doesn't have an SLN of its own that fails.
All the Nuget Packages are in place in a Packages directory, but I continue to get these errors. I just can't figure out what it wants from where.

After making the new changes, did you try building and testing your project in Visual Studio on your local machine? Did the same error occur?
The error generally is caused by that a type or namespace that is used in the program was not found. You might have forgotten to reference the assembly that contains the type, or you might not have added the required using directive. Or, there might be an issue with the assembly you are trying to reference. For more details, you can see "Compiler Error CS0246".
You can try the following steps in Visual Studio on your local machine to see if the error can be solved:
Correct the name of the namespace. You can use the drop down menu "Intellisense" also known as "Auto-complete".
Fix the custom namespace that was created.
And the following are few ticket for the similar issue as reference.
Getting "type or namespace name could not be found" but everything seems ok?
https://www.codeproject.com/Questions/5277362/Csharp-the-type-or-namespace-name-could-not-be-fou
[UPDATE]
If the DLLs are some of your custom or private references, to use this DLLs when building your project in Azure Pipelines on Azure DevOps, I recommend that you can publish these DLLs as a package to Azure Artifacts. And if you have any code update for the DLLs, you also can build and publish a new version of the package to Azure Artifacts.
After publishing the DLLs as package to Azure Artifacts, when building your project in pipeline, you can use the related task or command to restore the package into the specified path under the source directory of your project for use.
In your case, maybe you can try to publish these DLLs as a NuGet package.

Related

Xcode 12 - Error when building .m file because of " Could not build module 'std' "

I'm facing a problem I wasn't able to resolve in days.
I want to include some VTK header within my .m file, which works up to the point where some further linked VTK-Headers within the one I included tries to do:
#include <fstream>
An error occurs saying
'fstream' file not found
After some googling I came across the solution to add the following to my 'Header Search Paths':
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/"
The file now seems to be found, but some new errors occurred.
Could not build module 'std'
Unknown typename 'namespace'
Unknown typename '_LIBCPP_BEGIN_NAMESPACE_STD'
Unknown typename '_LIBCPP_END_NAMESPACE_STD'
Expected ';' after top level declarator
etc.
These occur whithin __nullptr, cstddef, type_traits.
I also tried to change the "C++ Standard Library" from 'Compiler Default' to 'libc++' or 'libstdc++', but nothing worked.
Does anybody know how to resolve this?
Additional Information:
macOS Big Sur 11.2.3
Xcode 12.4
arm64 architecture

The type of namespace 'Logging' does not exist in the namespace 'Sitecore'

Added Sitecore.Logging dll (from nuget) in the project but I still get the error.
It was working fine until I added a log4net dll (as part of some other nuget dependency). After this there was an ambiguous reference error. Then when I tried to specify Sitecore.Logging.LogManager/ Sitecore.Logging.ILog I get the error .
The type of namespace 'Logging' does not exist in the namespace 'Sitecore'
The Sitecore.Logging.dll does not contain classes in the Sitecore.Logging namespace, though you may be forgiven for expecting that to be the case - it is certainly the convention.
Opening it up with a decompiler reveals a forked version of log4net hiding in there.
You are probably looking for the log factory in Sitecore.Diagnostics.Log in the Sitecore.Kernel.dll
Right click the newly added log4net dll -> properties -> Aliases-> give a different name like 'log'. This will resolve the ambiguity in the code.

Referencing libraries from other solution

I have custom library that is located in a separate solution. When I reference that library in a new solution everything works fine, except when I try to build it. I get the error:
Error 1401 Failed to load assembly Utilities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Error 1402 Failed to resolve assembly: 'Utilities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
Anyone had similar problems?
Thank you
Solved
Since Dot42 does not have Tuple class I created my own Tuple in my library and used the same namespace (System). Looks like there's a problem System.* namespaces are used. I wanted to use the same namespace to avoid defines in using clauses.
Once I changed namespace it started working :)

What can cause ambiguous symbol errors on one computer and not another?

I'm using Visual Studio 2010 to work on C++ code. The project and all its contents have been written by someone else, and copied onto a shared drive. When the creator builds it on his computer, it works fine. When I try to build the solution, I get a whole bunch of these errors
error C2872: '<lambda0>' : ambiguous symbol could be
'[File].cpp(66) : anonymous-namespace'::<lambda0>' or
'[Different file].h(549) : `anonymous-namespace'::<lambda0>'.
Here's an example of a line which is said to be in error:
std::pair<int, std::pair<int, Point>> b) -> bool { return (a.second.second < b.second.second ); });
It seems like the error always occurs with a line which ends in '});'. The full code is rather enormous to show here, and it works on other computers, so presumably it's a problem with my settings or something. Can anybody hazard a guess as to what they may be?
Not sure if you've seen this or not but according to MSDN page for that compiler error:
C2872 can occur if a header file includes a using Directive (C++), and a subsequent header file is #include'd and contains a type that is also in the namespace specified in the using directive. Specify a using directive only after all your header files are specified with #include.
MSDN Page
I have had the same issue withe ambiguous symbol problem. For me, it turns out that I was using two namespaces which have the same function but obviously different definitions. I have to stop using one of the namespaces and this solve the issue.
As an example:
using namespace cv;
using namespace boost::accumulator;
accumulator_set<double, stats<tag::mean, tag::variance> > acc;
double meanval = mean (acc);
This will through a compilation error: error C2872: 'mean' : ambiguous symbol This is because both namespaces cv and boost::accumulator have the same function "mean"
I hope this helps
I have had the same issue
Installing VS2010 SP1 fixed the ambiguous anonymous-namespace'::<lambda0> issue for me. VS2010 without the SP1 has problems with lambdas.

Subsonic 3.0.0.4 Generates Compiler Errors

I am using the latest ActiveRecord template files and have generated my classes. However I am getting this error in my Context1.cs class ...
'SubSonic.Schema.IColumn' does not contain a definition for 'First' and no extension method 'First' accepting a first argument of type 'SubSonic.Schema.IColumn' could be found (are you missing a using directive or an assembly reference?)
Download the latest build from https://github.com/subsonic/SubSonic-3.0