I'm working in a Virtual Machine as a Hudson Slave.
In the virtual machine, I add the path to the MSBuild I want to use :
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\;
I added also the path to NUnit :
C:\Program Files\NUnit 2.5.7\bin\net-2.0;
And so, I can run the NUnit and MSBuild command lines in my VM.
But I get this error when my Hudson Job build my solution :
C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3245: Could not resolve this reference. Could not locate the assembly "nunit.framework".
What should I fix in my VM or in Hudson?
Thank you a lot!
EDIT
Here how the concerned file *.csproj references to the dll :
<Reference Include="nunit.framework, Version=2.5.7.10213, Culture=neutral, PublicKeyToken=KKKKKKKKKK processorArchitecture=KKK">
<SpecificVersion>False</SpecificVersion>
<HintPath>Dll\nunit.framework.dll</HintPath>
</Reference>
The issue isn't the nunit-console.exe (or whatever the name).
The issue is that you cannot find nunit.framework.dll...as a reference in your project file (.csproj for C#).
Your unit-test project, you need to open it and find how/where the reference to the nunit.framwork.dll is wired.
Post the .csproj code if that is confusing.
EDIT:
<HintPath>Dll\nunit.framework.dll</HintPath>
The issue is that you need to "download" or copy or svn-export or svn-checkout or nuget-get that file.
And place it in the relative directory to your .csproj.
Because you have specified a HintPath, it will NOT find the one in this below directory:
C:\Program Files (x86)\NUnit 2.X.Y\bin\nunit.framework.dll
Basically, the HintPath says "I expect to find this file HERE", and your MSBUILD error says "I did not find it where the HintPath said it would be."
Under which user account does jenkins-slave.exe (or hudson slave) run on your VM node?
Paths to .NET dlls are registered in windows registries (HKEY_CURRENT_USER\SOFTWARE\Microsoft\.NETFramework\VersionMinimum\AssemblyFoldersEx\MyAssemblies]#="AssemblyLocation").
By default jenkins runs jenkins-slave service under NT AUTHORITY\SYSTEM account (who probably doesn't have any AssemblyLocations registered on your system).
I filled my user acount login (under which the .csproj builds like a charm) details into jenkins -> nodes -> VM -> config and additionally set that same user account under which Windows runs the "jenkins slave" service (in VM's Windows Services -> jekins slave -> properties -> Log on -> This account: ...)
So it's working without specifying hint path in .csproj, because it is machine specific (my builds are running on multiple machines).
In my case, the issue was in the build sequence.
Required libs were configured to build after the failed one.
Related
I created an Azure Devops Build pipeline and i am trying to build my ASP.NET MVC and Angular hybrid site project on bitbucket (git).
The project first gets checked out, and nuget restores the necessary packages, and then the .NET builds. I used windows 2019 as azure pipeline agent for the build to succeed. however, Its taking about 7 minutes to complete, whilst running the tasks (besides .Net) on a ubuntu agent is much faster! takes around 2 mins instead!
Therefore, I'd like to use ubuntu, but im running into an issue with the MSBuild task...
"/home/vsts/work/1/s/Bobby.ProjectA/Bobby.ProjectA.csproj" (default target) (1) ->
(KillVBCSCompilerAndRetryCopy target) ->
/home/vsts/work/1/s/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8/build/net45/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(23,5):
error MSB4044: The "KillProcess" task was not given a value for the required parameter "ImagePath". [/home/vsts/work/1/s/Bobby.ProjectA/Bobby.ProjectA.csproj]
According to this post, VBCSCompiler.exe continues running from the Compiler Nuget package (nuget restore task?) so it locks the src folders and prevented future builds from running, e.g. causing error like this:
/home/vsts/work/1/s/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8/build/net45/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(17,5):
warning MSB3021: Unable to copy file "/home/vsts/work/1/s/packages/Microsoft.Net.Compilers.2.4.0/build/../tools/csc.exe" to "/bin/roslyn/csc.exe". Access to the path '/bin/roslyn' is denied. [/home/vsts/work/1/s/Bobby.ProjectA/Bobby.ProjectA.csproj]
So the solution would be to kill the VBCSCompiler.exe but since i cant actually access the hosted machine during the build, im not sure how to do that.
screenshot of my pipeline so far:
Am i facing a dead-end path here with this approach? The build runs fine on windows 2019 but it just takes too long, so thats why if i can make it run on ubuntu successfully that would be great!
You can have a try with below workarounds:
1,Set MSBUILD arguements /p:UseSharedCompilation=false.
You can add above arguement to the msbuild arguements field of the msbuild task. See here.
2,Upgrade Microsoft.CodeDom.Providers.DotNetCompilerPlatform nupkg to the latest and remove Microsoft.Net.Compilers nupkg from your project. See here for more information.
3, Try Specifing the TTL of Roslyn compiler server.
You can define a pipeline variable VBCSCOMPILER_TTL on the Variable tab to specify a shorter idle time for VBCSCompiler.exe
Or you can add <providerOption name="CompilerServerTimeToLive" value="[num of seconds]" /> under system.codedom/compilers/compiler in the config file. See here for more information.
4, Use CheckIfShouldKillVBCSCompiler target:
You can try add below to your csproj file:
<Target Name="CheckIfShouldKillVBCSCompiler">
<PropertyGroup>
<ShouldKillVBCSCompiler>true</ShouldKillVBCSCompiler>
</PropertyGroup>
</Target>
See here.
The build on Ubuntu 20 finally worked! I don't know why removing these lines resolved the VBCSCompiler issue, but by doing so, the msbuild completed successfully on Ubunutu 20 agent!!
Remove the following lines from the .csproj file:
<Import Project="..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props')" />
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
To give some context to the answer, this post here indicated that converting from MSBuild-Integrated Package Restore to Automatic Package Restore (nuget restore task) implied that the Microsoft.Net.Compilers <Import> and <Error Condition> snippets are no longer relevant/needed in the .csproj file.
I have a solution running on VS 2017 15.7.4 on Windows 7 and works on 6 machines.
On this new machine (same like the others), I am getting the following when I am trying to compile:
The command ""C:\Projects\MySolution\Source\.nuget\NuGet.exe" install "packages.config" -source "" -NonInteractive -RequireConsent -solutionDir "C:\Projects\MySolution\Source\ "" exited with code 1
Could not find file 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\packages.config'.
We tried showing detailed build log, but that wasn't helpful
We rebuilt the machine and same error persisted.
This is a corporate machine with local admin right user account. I am suspecting that the local admin rights might not be implemented properly.
Any suggestions?
NuGet with MSBuild Trying to locate the package.config in VS IDE
folder
Please try to give the full path to the packages.config file:
"C:\Projects\MySolution\Source\.nuget\NuGet.exe" install "<YourProjectPath>\packages.config" -source "C:\Projects\MySolution\Source\"
After hours of investigation, it turned out that the project name is the problem.
The project name (and the namespace) are as follow: MyCompany.MyProject.CMD
(CMD is actually real).
This project was compiling for ages on all machines, however, it didn't do on this particular machine.
We deleted the whole folder structure and recreated it and even formatted the machine.
We tried creating a new project from scratch and calling it the same name - Didn't compile
We tried creating a new project from scratch and called it a different name - Worked!
So solution was changing the project name to MyCompany.MyProject.SomethingElse sorted out the problem. I didn't add CMD as part of the project name, but I will never do and I will pass this to my kids as well.
I didn't want to investigate why it didn't work but CMD resembles the name of the Windows console, would that be the reason? I don't care to know.
I try to integrate StyleCop in a Visual Studio solution. Installing StyleCop on each machine of each developer is something I would prefer to avoid. The suggestion I've seen several times (example) is to include the binaries of StyleCop within the project, storing them in version control.
I did that. It works on my machine, but fails on a different machine where StyleCop is not installed. After uninstalling StyleCop on my machine, it doesn't work there either.
The error message is the following:
Severity Code Description Project File Line
Error The "StyleCopTask" task could not be loaded from the assembly C:\Program Files (x86)\MSBuild..\StyleCop 4.7\StyleCop.dll. Could not load file or assembly 'file:///C:\Program Files (x86)\StyleCop 4.7\StyleCop.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. Demo
This is what I included in every .csproj file:
<Import Project="$(SolutionDir)\externs\Microsoft.StyleCop\StyleCop.targets" />
The directory C:\demo\externs\Microsoft.StyleCop contains:
The copy of all the files from C:\Program Files (x86)\StyleCop 4.7,
The copy of C:\Program Files (x86)\MSBuild\StyleCop\v4.7\StyleCop.Targets.
What's wrong?
It appears that StyleCop.Targets contains an absolute path:
<UsingTask
AssemblyFile="$(MSBuildExtensionsPath)\..\StyleCop 4.7\StyleCop.dll"
TaskName="StyleCopTask"/>
In order to be able to use StyleCop on machines where the application is not installed, change this path to something similar to:
<UsingTask
AssemblyFile="$(SolutionDir)\externs\Microsoft.StyleCop\StyleCop.dll"
TaskName="StyleCopTask"/>
I have a project that was recently switched from svn to git. It was also just upgraded to VS2012, but the .NET/MVC versions remain the same. I can still build it fine on my local machine, but now the machine I use for CI is giving me the following error:
LC : error LC0000: 'Could not load file or assembly 'ActiveReports3, Version=5.2.1178.2, Culture=neutral, PublicKeyToken=cc4967777XXXXXX' or one of its dependencies. Access is denied.'
The job is being fired off by jenkins and is correctly pulling the right branch down from git, and I have verified that activereports3.dll is in the project directory, with full permissions. Any other ideas as to what might be causing this? Haven't turned up any other ideas on Google. Thanks!
Open up the .csproj (from before the conversion and then after the conversion) in notepad (or other text editor) and see if the hintpath for the ActiveReports3 was altered. Perhaps to a "hard path" like "C:\Program Files\ActiveReports\ActiveReports3.dll" or similar.
I just need to create Web Deployement package using TFS build and don't want to deploy it automatically in IIS.
I have added the below two parameters in Build Definition - > MSBuild Arguments
/p:CreatePackageOnPublish=true /p:DeployOnBuild=true
The probelm is I am not getting the ZIP file in drop location and getting the below error.
C:\Program
Files\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets
(1657): The "MapUriToIisWebServer" task failed unexpectedly.
System.Runtime.InteropServices.COMException (0x80005000): Unknown
error (0x80005000) at
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind() at
System.DirectoryServices.DirectoryEntry.get_IsContainer() at
System.DirectoryServices.DirectoryEntries.CheckIsContainer() at
System.DirectoryServices.DirectoryEntries.Find(String name, String
schemaClassName) at
Microsoft.Web.Publishing.Tasks.MapUriToIisWebServer.get_IisMajorVersion()
at Microsoft.Web.Publishing.Tasks.MapUriToIisWebServer.Execute() at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at
Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost
taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost
taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask,
Boolean& taskResult)
What could be the issue?
Now I am getting different error
error : Web deployment task failed.(Object of type 'manifest' and path 'e:\TFS\Dev\ApplicationName\Binaries\Release_PublishedWebsites\ApplicationName_Package\ApplicationName.SourceManifest.xml' cannot be created.)
error : Object of type 'manifest' and path 'e:\TFS\Dev\ApplicationName\Binaries\Release_PublishedWebsites\ApplicationName_Package\ApplicationName.SourceManifest.xml' cannot be created.
error : One or more entries in the manifest 'sitemanifest' are not valid.
error : Application '/ApplicationName' does not exist in site 'Default Web Site'.
I believe you just need to add the 'Package' target to your build for the web project.
/t:Build;Package
I've been using that target in my tfs build to generate the _PublishedWebsite folder with the package zip for a while now with success.
EDIT: Explanation of Package target
If you look at your csproj file for your web application as an XML file, you'll see that it includes the following
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
This includes a bunch of web targets into your build process. Crack this file open and at the bottom you'll see that it in turn includes
<Import Project="..\Web\Microsoft.Web.Publishing.targets" Condition="Exists('..\Web\Microsoft.Web.Publishing.targets')" />
This file contains the definition of the Web Deployment process for MSBuild. You'll see that it declares a variable to denote the "target" to invoke on a Deploy as being "Package"
<DeployDefaultTarget Condition="'$(DeployDefaultTarget)'==''">Package</DeployDefaultTarget>
If you read through this file further it will give you an idea of how Packaging and Deployment work under the covers and what the set of properties and targets are you can manipulate to customize your build.
Long story short though, if you call
msbuild yourwebapplication.csproj /t:Package /p:Configuration=Release
It should build you the web deployment package for the Release configuration of your app.
I had the same issue and the only thing that resolved it was this:
Open your IIS Management console
Go to your Default Web Site
Add new Application named 'ApplicationName'
Run msbuild again. It will work.
Possible duplicate of MSBuild DeployOnBuild=true not publishing
I had the same problem with Atlassian Bamboo, and this fixed it for me: From a machine with Visual Studio copy the contents of "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web" to the TFS Build server.