Task could not be loaded from assembly - c#

I have an error in one of my projects at work. The error says:
Severity Code Description Project File Line Suppression State
Error The "StyleCopTask" task could not be loaded from the assembly
C:\Projects\Project
Name\Source\\MSBuild\StyleCop\v4.7\StyleCop.dll. Could not load
file or assembly 'Microsoft.Build.Utilities.v3.5, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 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. DskDirectMarketing.Common
Here I can clearly see that there is problem in the relative path which VS is looking for StyleCop. Here is how it looks like:
<Import Project="$(SolutionDir)\MSBuild\StyleCop\v4.7\StyleCop.targets" />
and my SolutionDir declaration looks like this:
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
After some digging I noticed that in the error which prompts me there are 2 slashes:
C:\Projects\Project Name\Source\MSBuild\StyleCop\v4.7\StyleCop.dll
First thing I tried was to remove the dash from
<Import Project="$(SolutionDir)MSBuild\StyleCop\v4.7\StyleCop.targets" />
Id didn't worked.
After that I tried to put the absolute path but I had 2 slashes again.
How can I resolve this issue? Any help would be appreciated.

Based on #MaKCbIMKo's answer I installed .Net Framework 3.5 and this fixed my problem.

If you are using Windows 10, enable the .net framework 3.5 and if does not allow you to do so, open command prompt and run:
Dism /online /enable-feature /featurename:NetFX3 /All /Source:D:\sources\sxs /LimitAccess

If you're also using Visual Studio 2019 on Windows 10, you could try the following:
Close your Visual Studio instance.
Open Visual Studio Installer.
On the version of Visual Studio that you're currently using, click on More and select Modify.
Select the Individual components tab.
Search for .NET Framework 3.5 development tools, select it and click on Modify.
Wait for the modification to finish.
Open your project in Visual Studio, then do a Clean, followed by a Build.

In my case the paths were correct, but visual studio needed to run under elevated permissions to access the file in question.

We need to use visual studio installer to install the .netframework 3.5 , if the visual studio installer shows both options Visual Studio 2019 and Visual studio Build Tools 2017. follow below step
If you are using the Visual Studio 2019 ( mine was 16.11.3 but should work for all the versions). you will have Visual studio 2019 and Visual studio build tools 2017 .
Select the Visual Studio Build Tools 2017 => select modify => go to individual components => select .Net Framework 3.5 development tools
Then proceed with the installation.
-Ideally it should work once you re open the Visual studio , if not restart the system

Related

Visual Studio Build Fails due to Error: MSB4025

Hi I am trying to run dotnet build <Sln file> to build the project but I am getting this error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.
Build Failed
Folder Structure: C:\Users\USERNAME\PROJECTNAME\Folder0\File0.vdproj(1,1)
Dotnet Version: 6.0.301
I think that this information is useful.
vdproj is a MSI creation project for Visual Studio. Its been deprecated and most people have moved on to either WIX or NSIS or a professional grade installer creation tools such as Install Shield. If you do not require an installer for your product just exclude the vdproj project from the solution and continue with your life. For fun if you want to try to transition right away to wix, try this powershell script https://github.com/chrisoldwood/vdproj2wix
Visual Studio - vdproj is incompatible
MSI setup (.vdproj) This project can't be opened in Visual Studio 2013 because it doesn't support that project type. We recommend that you use InstallShield Limited Edition for Visual Studio (ISLE), a free deployment solution that directly supports most Windows platforms and application runtimes. You can also use ISLE to import data and settings from Visual Studio Installer projects.
Port, migrate, and upgrade Visual Studio projects

.NET Core 1.0.1 VS 2015 Tooling Preview 2 without Visual Studio installed

I found many topics regarding this issue but it looks like it none of them can help me. I'm trying to install DotNetCore.1.0.1-VS2015Tools.Preview2.0.3.exe without Visual Studio installed - basically it's our build machine. When I run executable I get: "This product requires Visual Studio 2015 ..." . I've already tried to use SKIP_VSU_CHECK=1 and it didn't help.
Context:
We have TeamCity server build agents hosted on different machine and we don't want to install Visual Studio there. One of our project is *.xproj project and it cannot be built due to the following error: " error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
What I found so far is that I should install Vs2015Tools in order to build it. I have already installed .NET core SDK.

Build an executable file without Microsoft Visual Studio from project file

I don't have MS Visual Studio installed and can't install it due to financial/legal reasons. I've inherited an executable file built with Visual Studio using C#. It isn't working as planned. I can fix the problem by changing 1 line of code. I have done so, but now I don't know how to re-build the project into an executable without Visual Studio.
I've tried running the following code from the command prompt:
>C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:exe
/out:exchange.exe exchange.csproj
Am I on the right track?
Edit: This question is different from this question because here I ask about building and compiling a whole project... not just a .cs file.
I would suggest installing Visual Studio Community edition (free)
But, if you just want to build using msbuild through the commandline the simplest way would be (assuming you navigated to where msbuild is or have the env path set):
msbuild "C:\Users\Something\Documents\Visual Studio 2015\Blah path\Hello.csproj"
Building (then running) a simple console app that prints hello with the above:
You can use MonoDevelop for compiling your C# project.

Error in Visual Studio 2015 When Add New WebForm

When I add new WebForm to my project, I get the following error:
Could not load file or assembly
'Microsoft.VisualStudio.JSLS,Version=14.0.0.0 , Culture=neutral ,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.the system
can not find the file specified.
I tried to create new website project and I tried to reinstall VS 2015 but this did not help.
This is a known bug with Visual Studio 2015. The officially-endorsed solution from Microsoft has been posted on MSDN:
If the “Tools for Universal Windows Apps Development” are still installed:
Go to Programs and Features, select Visual Studio 2105, click Change.
In Visual Studio setup, click Modify.
Deselect the feature “Tools for Universal Windows App Development”
Select “Tools for Universal Windows App Development” again, and click Update.
If you have already uninstalled the “Tools for Universal Windows Apps Development”:
Reinstall “Tools for Universal Windows App Development”
Or take the following steps to reinstall the JavaScript project system and language service:
a. Download the installer for your edition of Visual Studio, e.g.,
vs_community.exe.
b. Open a CMD window, and run the following command:
vs_community.exe /modify /installselectableitems JavaScript_Hidden
/passive
A temporary solution:
Shut down Visual Studio and reinstall the following package from the DVD or ISO:
x:\packages\JavaScript_LanguageService\JavaScript_LanguageService.msi
A better solution, endorsed by Microsoft, has been posted.
Remove the update received for visual studio TypeScript on 11/08/2015. it seems to be buggy. After removing TypeScript update, my VS is working fine ;-)
and if you try to reinstall x:\packages\JavaScript_LanguageService\JavaScript_LanguageService.msi from the installation package, soon or later you will face one more problem that "Something went wrong.. may be because of a extension.."
Easiest way is to remove TypeScript update for now. TypeScript future update may fix the problem.
OR
Run command prompt as administrator.
CD C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
devenv /updateconfiguration
devenv /clearcache

Visual Studio 2012 project won't open in 2010

I've created a game for an assignment in Visual Studio 2012 and the university I'm at uses 2010 and it won't open! It mentions something about NET Framework 4.5. How can I convert my project so it will open in 2010?
It takes three step:
Step 1
Open solution file (.sln) in a text editor and change
Microsoft Visual Studio Solution File, Format Version 12.00
to
Microsoft Visual Studio Solution File, Format Version 11.00
Step 2
Open application configuration file (App.config) in a text editor and change
sku=".NETFramework,Version=v4.5"
to
sku=".NETFramework,Version=v4.0"
Step 3
Open project file (for C# language .csproj) in a text editor and change
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
to
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
Now enjoy your project in VS 2010 !
You may only need to open the project in Visual Studio 2012, and go to the project's properties page.
On the Application tab, locate the Target Framework setting, and change it to .Net Framework 4.
After that, you should be able to open it in Visual Studio 2010.
Also see Converting VS2012 Solution to VS2010, but so far I haven't had to do any conversions on VS2012-created projects to open them ins VS2010 - but YMMV.
[EDIT]
I just tested this again (to be sure) by creating a .Net 4.5 project in VS2012, and verified that I couldn't open it in VS2010. Then I opened it in VS2012 again and changed the framework version to .Net 4.0. After that I could open it in VS2010.
Note that I didn't have to make any other changes. However, this is on a computer with VS2010 and VS2012 installed, so it's possible that installing VS2012 might do something with VS2010 to make it work...
I have done this at work
Open .sln file with notepad
Change the two lines below
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
To
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
and hey presto the solution now opens in VS2010
You can create a new project in Visual Studio 2010 and then right click in the solution explorer > Add > Existing item. To pull through all of files in your 2012 project.
Either create a new solution in VS2010 and add all existing files from your VS2012 or compare the .sln file to a .sln file freshly created with VS2010. At the top you'll see some version information that should be changed. Also compare the .csproj files and change any version information accordingly and the target framework.
Missing library or framework could also cause this problem. For example, if you want to open a MVC4 or Silver Light project but you don't have these libraries installed at your PC.
Open .sln file and Change Format Version to 12.0 to 11.0

Categories

Resources