0

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.

StephanM
  • 1
  • 1

1 Answers1

0

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:

  1. Correct the name of the namespace. You can use the drop down menu "Intellisense" also known as "Auto-complete".

  2. Fix the custom namespace that was created.

And the following are few ticket for the similar issue as reference.

[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.

Bright Ran-MSFT
  • 1,554
  • 1
  • 1
  • 5
  • We do not get the same error within Visual Studio 2019 as it seems to build the bin directory as expected. If I copy my files from my local Bin directory to the build servers bin directory and queue the build again it will works. I just can't figure out how to get MSBuild to behave the same as VS2019. – StephanM Mar 31 '21 at 12:53
  • To get the build to work I ended up creating a directory called C:\Program Files (x86)\Common Files\Microsoft Shared\VSTT\16.0\UITestExtensionPackages and put the DLL's for Microsoft.ExtendedReflection and Microsoft.Pex.Framework. How is this directory really suppose to be created on a build server using build tools / MSBuild? – StephanM Mar 31 '21 at 16:39
  • Hi @StephanM, I have updated my answer with more suggestions. Please check it. – Bright Ran-MSFT Apr 01 '21 at 08:07
  • Microsoft.ExtendedReflection and Microsoft.Pex.Framework are not part of a Nuget Packages now get errors like Test run detected DLL(s) which were built for different framework and platform versions. Following DLL(s) do not match current settings, which are .NETFramework,Version=v4.0 framework and X86 platform. – StephanM Apr 01 '21 at 17:05