I have a project on ASP.NET Web API that has references to many libraries. When we tried to do our usual CI/CD to the App Service via Deployment Center. We faced with issues.
We need to remove .csproj in order for the deployment to work else we are facing this error on server
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.
However we require the csproj files for the various members in the team to work together for this particular project.
In this case, what is the likely solution that we can adopt?
Problem: The source control will only contain references for the binaries. The packages should be restored before a build can be triggered.
Fix: Add a step in your CI/CD to restore the NuGet packages in the project before you trigger a build. Ref attached image.
Related
I have my windows forms application with WindowsAPICodePack but i don't know where should I put the package in the release folder, and without it the program just gives me an error (it's in Hungarian so I don't think anybody can understand, but it said that it can't find the windowsAPICodePack, the version number, culture and publickeytoken) on another PC, on mine it works.
Depending on if your application is using a packages.config file to manage packages or if your project is using package references (PackageReference) will determine path to solution.
When a package is installed it records the package identifier and version into the project file or packages.config file in your solution workspace.
If using a package.config to mange packages then ensure your packages are getting installed in the location as expected, possibly clearing the cache will help to ensure proper version is installed.
find out the packages folder where your application is trying to load the references.
Possibly config binding redirects.
Clear you package cache and reinstall. use the package manager ui for your ‘debug’ and ‘release’ MSBuild configs to ensure the package is being referenced correctly.
Verify your nuget.xml settings file for locations of packages
Read all the version or property values to use for your application. Ensure you are configuring the release target as expected.
Here are some links to help you config the correct setup for your approach:
Package reference via project files
if using - Packages.config settings
Config setting for Nuget
NuGet settings
Note: for simplicity if this is just a school project then just remove all NuGet packages references and find the dll . Then just add reference to dll and check the property to include in output . This will give you a simple folder with all the files needed to run your app from pen-drive
I am trying to achieve setting up a vNext build definition on TFS 2015 (the project is actually a .NET 4.6.1 web project, but I want to use the new TFS build setup). I am struggling with finding documentation on only deploying a specific web project in my solution (2 web projects, 3 class libraries and subsequent tests).
In the XAML build approach, I would specify the .sln and the .csproj file relevant to the build in the Process > 2. Build > Projects input. The "Visual Studio Build" step does not allow for multiple project inputs in the same way, and this seems to be where I am getting stuck. If I only specify the .csproj, Nuget packages do not get restored and the build fails.
Is there any known documentation for deploying a C# web project (.csproj) ONLY via these vNext builds?
MSBuild arguments previously used in XAML Build:
/p:AllowUntrustedCertificate=True /p:AuthType=NTLM /p:Configuration=Development /p:DeployOnBuild=True /p:PublishProfile="DEV" /toolsversion:14.0 /p:VisualStudioVersion=14.0 /p:GenerateBuildInfoConfigFile=false
The solution I am searching for would accomplish the following:
Builds at the very least the Web.csproj with project dependencies
Restores Nuget packages
Transforms web configs
Deploys Web project to two separate servers (non-Azure!) via, ideally, web deploy
Thanks in advanced for any help. Hopefully this is possible!
Note: I am not on Azure and Azure is not an option. I know there are tons of documented use case scenarios for Azure users, which is great... but, yeah.
You can add a "NuGet Installer" task at the top of your build definition to restore the nuget packages for your solution and specify the .csproj in Visual Studio Build Step.
If you want to build the entire solution, you can add following arguments in "MSBuild Arguments":
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"
This will create the deploy packages for your projects separately in "$(build.artifactstagingdirectory)\" folder like following:
Then you can choose the package for the project you want to deploy. And with the deploy package, you can add two "Command Line" tasks in your build definition and call "Project.deploy.cmd" under "$(build.artifactstagingdirectory)\" folder to deploy the project to your servers. Reference about deploy from command: Executing the Command File. Web.config will be transformed by default if you have configured it correctly.
By the way, I recommend you to deploy your projects by using the release management system instead of deploying them in build.
I have several WCF and WebAPI services as well as MVC websites in a visual studio solution. Currently, we are creating WebDeploy packages for these services and websites to deploy to IIS. I'm starting to look into Octopus Deploy for deploying our services and websites instead of WebDeploy. However, Octopus Deploy uses Nuget packages to deploy.
I'm trying to figure out how I can easily create a Nuget package that contains all the files that would normally be published into a WebDeploy package. This may not be all files in the project directory or the bin directory. I found this blog post describing how to package a csproj into a Nuget package during the build, but I found that the resulting package didn't contain any of my dependency dll's. I realize I could write a nuspec for each of these projects manually and include exactly the files I want, but I'm looking for a more automatic way as this would create more maintenance when my project changes.
Does anyone out there know a good way to generate a nuspec or Nuget package that contains only the files needed to run the application, similar to the way publishing to a WebDeploy package only includes the files it needs?
Octopus Deploy has a CLI called "Octo.exe" that can package up your application into a NUPKG.
You will need to install Octopus Tools which you can download from https://octopus.com/downloads
Please see http://docs.octopusdeploy.com/display/OD/Using+Octo.exe for the documentation and how to use it.
A good example to use Octo.exe is part of a Continuous Integration pipeline when the build has successfully passed you call it to package the application and send it to the Octopus server.
After some playing around with Visual Studio, MSBuild, and TeamCity, I discovered a method that works for me. My issues was that I did not want to package up all the files in my project directory, only those that are necessary to run the application. WebDeploy handles this quite nicely as one of the options when publishing. I already have settings in my csproj file that will create a WebDeploy package on build, but this is a zip file and I don't want the zip file in my Nuget package.
I found 2 ways to deal with this:
In TeamCity, I set up a new Build Configuration that will package any nuspec files I have and publish the resulting Nuget packages to my Octopus Deploy Nuget feed. I figured out that I can use the existing WebDeploy package that gets created by my CI build configuration as an artifact dependency and TeamCity can actually unpack the zip file when grabbing the artifacts as part of that dependency. Then my nuspec file references the entire folder structure that was extracted from the zip file and packages it into a Nupak.
I was able to modify my csproj settings to use a specific publish profile I generated in Visual Studio that would perform a WebDeploy package to file system. This would result in the same folder structure as is in the zip file from #1, but simply copied to a directory. Then my Nuget build configuration could simply grab those dependencies and package them the same way as in #1.
I decided to go with option #1 as it would require minimal changes to my existing csproj and CI build configuration, and it would not break our current method of deploying using WebDeploy.
I have a project that I have on TFS online. When Im trying to build the project, I get the following error:
Severity Code Description Project File Line
Error The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly C:\Users\Bryan\Source\Workspaces\TestProject\ContosoUniversity\packages\Microsoft.Net.Compilers.1.0.0\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll. Could not load file or assembly 'file:///C:\Users\Bryan\Source\Workspaces\TestProject\ContosoUniversity\packages\Microsoft.Net.Compilers.1.0.0\tools\Microsoft.Build.Tasks.CodeAnalysis.dll' or one of its dependencies. Could not find the file. 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. ContosoUniversity
Has this something to do with that Azure don't support ASP.NET 4.6?
Here was the fix for me. Using Nuget Package Manager, remove these two packages if referenced:
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Microsoft.Net.Compilers
After that, run a rebuild. This ensured that the build was not trying to use a specific build exe. Click here for the Diff against previous revision
No, it is not related to Azure Web Apps doesn't support ASP.NET 4.6. Actually, you get this error message because NuGet packages are checked into version control.
So, you need to remove folder TestProject\ContosoUniversity\packages from TFS and build again. See: BuildTasks.Csc task could not be loaded from the assembly?
I had the same problem sometime ago, to fix it:
make sure your packages are not under source control
Force restore all package, by deleting the package folder
restart your visual studio
In my case it got resolved by updating the below two Nuget packages to the latest version:
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Microsoft.Net.Compilers
Delete the packages folder or its contents, clean, rebuild solves the problem for me.
If you take a look at the file in reference it points you to a packages location. It turns out that NuGet packages is broken
To Resolve: you simply need to delete that packages folder (usually under project name \ project name \ packages.), then on build, Nuget will restore all the required packages.
I needed to update all my Nuget packages on my development box, then check the project in to TFS again.
For added peace of mind, I deleted the packages folder in the Team City build folder.
In case someone looks at this later on.
I was getting this issue only when building in DevOps.
But after manually deleting packages in my local build I started getting the same issue locally.
After removing the apparently missing NuGets using the NuGet manager the issue resolved it's self both locally and on azure.
Not sure what caused it but might save someone a headache in the future.
I was using .net 4.7.2
I'm trying to migrate all my C# projects to new Nuget Automatic Restore, following this tutorial: Migrating MSBuild-Integrated solutions to use Automatic Package Restore
I've successfully done it to my desktop/libraries projects, which I had to edit .csproj files, removing these lines from it (I'm not using TFS):
<RestorePackages>true</RestorePackages>
...
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
...
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
However, WebSites don't seem to have any .csproj or any other file containing these instructions. When I install a package, it sucessfully put the .dll inside my packages folder, but it also put in bin folder. If I select the .dll under /bin within Solution Explorer, it has the following properties:
Auto-refresh path: C:\mypackages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll
File Name: Newtonsoft.Json.dll
Full Path: C:\MyWebSite\Bin\Newtonsoft.Json.dll
This is set default when I first install a package from nuget. I think it should not look into bin folder, or when I build the project, it should bring the .dll to bin folder if it doesn't exist. The problem is if I build the project without the .dll in bin, it gives me the following error: "The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)". For desktop/libraries projects, the .dll is copied to bin folder.
I read in another question Nuget doesn't support WebSite, but Web Applications instead: NuGet Package restore for website, but I also read in Nuget's page that they have added compatibility to ASP.NET Web Sites, so here is my question: Am I doing something wrong? Or should I migrate to Web Application because they don't support Web Sites at all?
I also have the same problem described in the above question. I was wondering if you figured out how to do a nuget restore on the website without the project file. I do have a package.config in the website.
I tried a bunch of different things and the following command got me closer to a resolution, but not quite.
nuget restore packages.config -PackagesDirectory ..\packages
The above command does restore the packages into the ..\packages folder as expected, but I cannot figure out how to get the correct assemblies into the website's bin folder.
When you click "Enable NuGet Package Restore" in the right mouse button context menu on the solution in Visual Studio you get an info message shown which says:
Packages installed into Website projects will not be restored during
build. Consider converting those into Web application projects
necessary.
However there is a workaround I tried that works. Consider situation when you have a class library (DLL) project referenced by the Website project. If both projects reference the same NuGet package, then building whole solution the DLL project is built first, packages are restored correctly. Next step when it comes to the Website project the required package is already in place and its DLLs are copied into /Website/Bin/ folder according to the *.refresh file. Result - solution build finishes successfully.
I can definitely confirm that NuGet automatic restore feature actually works for Web Sites projects under VS with latest version of NuGet.
Make sure that:
You are using NuGet 2.7 or higher (Tools > Extensions and Updates > Updates)
There is no .nuget\NuGet.targets file at the solution root
You have packages.config in Web Site root with all references to the packages (normally generated by VS when adding NuGet packages)
Visual Studio is configured to "Allow NuGet to download missing packages" and "Automatically check for missing packages during build" in Visual Studio (see Options > NuGet Package Manager) - these are ON by default
Here what I see as the build output when some package for Web Site project is missing.
Restoring NuGet packages...
To prevent NuGet from restoring packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages during build.'
------ Build started: Project: WebSite1, Configuration: Debug Any CPU ------
Validating Web Site
Building directory '/'.
Validation Complete
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
Link that describes the above in details: https://docs.nuget.org/consume/package-restore.
Here is the solution to this problem and it does work.
If you have a separate business logic layer, you could install the nuget packages into that project. Then you can do the nuget restore on the business logic layer prior to doing msbuild on the website solution. When doing msbuild on the solution which contains the BLL and the WebSite it will pull all the referenced assemblies (including the nuget restored dlls) out of the BLL project into the website's bin folder.
Here is a hack option if you don't have a separate business logic layer.
Using NuGet with *.dll.refresh files in ASP.NET "Web Site" projects with Web Deployment Projects