Method System.IO.Path.GetDirectoryName not found when creating an application installer WPF - c#

Severity Code Description Project File Line Suppression State
Error MSB4186 Invalid static method invocation syntax:
"[System.IO.Path]::GetDirectoryName(C:\Users\emmet\OneDrive - CBRE,
Inc\Work\SourceTree\CBREDesktopApplication%28Net5Dev%29\CBRE
Application\CBRE Application.csproj)". Method
'System.IO.Path.GetDirectoryName' not found. Static method invocation
should be of the form: $([FullTypeName]::Method()), e.g.
$([System.IO.Path]::Combine(a, b)). Check that all parameters are
defined, are of the correct type, and are specified in the right
order. Application Installer C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\MSBuild\Microsoft\DesktopBridge\Microsoft.DesktopBridge.targets 602
When attempting to create an application installer for a WPF application, I get this error code on Visual Studio 2019. Any ideas? Project is .Net 5.0

Related

CreatePkgDef Exception in VS 2019

I am trying to create a visual studio extension for my Roslyn analyzer in VS 2019. When I set the option Generate .pkgdef File to true I am getting the below exception:
CreatePkgDef : error : ArgumentException: No Visual Studio registration attribute found in this assembly.
The assembly should contain an instance of the attribute 'Microsoft.VisualStudio.Shell.RegistrationAttribute' defined in assembly 'Microsoft.VisualStudio.Shell.Framework' version '16.0.0.0'
at Microsoft.VisualStudio.Tools.CreatePkgDef.ProcessAssembly(String fileName, Hive hive, PkgDefContext context, Boolean register, RegistrationMode mode)
at Microsoft.VisualStudio.Tools.CreatePkgDef.DoCreatePkgDef(InputArguments inputArguments)
at Microsoft.VisualStudio.Tools.CreatePkgDef.Main(String[] arguments)
In my case, I had one project that was originally tasked with making a VSIX AND contained a lot of classes/views/viewmodels. I wanted to create a separate VSIX installer project and started receiving this 'CreatePkgDef : error : ArgumentException: No Visual Studio registration attribute found in this assembly.The assembly should contain an instance of the attribute 'Microsoft.VisualStudio.Shell.RegistrationAttribute' error.
What worked for me was editing the original project's .csproj file to change true to false in this element:
<GeneratePkgDefFile>false</GeneratePkgDefFile>
If the < GeneratePkgDefFile > element does not already exist, simply add it within the < PropertyGroup > element near the top.

Why does build fail with the error - Type or namespace name '' could not be found in the global namespace

I am trying to build a project using visual studio as well as MSBuild.exe. When the code is built using visual studio, there are no issues and the build runs successfully, but when built through MSBuild.exe, the following error is thrown - "The type or namespace name 'eCom' could not be found in the global namespace". This error is being recorded from various lines in the code, couple of the erroneous lines have been written below:
protected global::eCom.Web.DataViewExtender view3Extender;
and
using eCom.Web;
The dll for 'eCom' is successfully getting created on the server.
Recently dot net framework 4.6.2 was installed on the build server, I wonder if that has anything to do with the error.

Visual Studio 2017 Extension Development

Hi I want to upgrade my extension to visual studio 2017 but I got Microsoft.VisualStudio.Shell.RegistrationAttribute error, but I have been already added this reference?I got this error in compile time. Is there any reference to be added or else? Any comment about that?
D:\Visual Studio 2017\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Shell.Immutable.10.0.dll ,version :10.0.0.0
My Error is
Severity Code Description Project File Line Suppression State
Error CreatePkgDef : error : ArgumentException: No Visual Studio registration attribute found in this assembly.
Severity Code Description Project File Line Suppression State
Error The assembly should contain an instance of the attribute 'Microsoft.VisualStudio.Shell.RegistrationAttribute' defined in assembly 'Microsoft.VisualStudio.Shell.Immutable.10.0' version '10.0.0.0'
Severity Code Description Project File Line Suppression State
Error at Microsoft.VisualStudio.Tools.CreatePkgDef.ProcessAssembly(String fileName, Hive hive, PkgDefContext context, Boolean register, RegistrationMode mode) in f:\dd\src\vssdk\VSIntegration\Tools\src\CreatePkgDef\CreatePkgDef.cs:line 303
Add GeneratePkgDefFile as false like below in the csproj file
<GeneratePkgDefFile>false</GeneratePkgDefFile>
Finaly I found the solution,I remove all references of Microsoft.VisualStudio.****,after than I add my project a new vsix in visual studio 2017 that time I download all packages from nuget and my project is compile now.

Make MSBuild use new Roslyn compiler in VS15 Preview

I just recently delved into Roslyn compiler stuff and I'm wondering about some possibilities. I'm trying to build Roslyn compiler from Roslyn repository using features/tuples branch and replace the needed DLLs in VS15Preview\MSBuild\15.0\Bin folder. But when I replace DLLs and build console app project I receive the following error message
Severity Code Description Project File Line Suppression State
Error The specified task executable "csc.exe" could not be run. Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Files which I try to replace: Microsoft.CodeAnalysis.dll, Microsoft.CodeAnalysis.Csharp.dll and csc.exe.
Is it possible to build your custom Roslyn compiler for C# and replace it within VS15 Preview?
One way of going about it is to set the CscToolPath msbuild variable to your new roslyn build's bin directory.
I find the msbuild commandline (e.g. Start > Developer Command Prompt) the most convenient for this. You can just cd into any solution directory on run:
msbuild /p:CscToolPath=<PathToYourRoslynBinDir>`
You can also do it inside a .csproj if you do it more often:
<PropertyGroup>
<CscToolPath>C:\your\roslyn\bin</CscToolPath>
</PropertyGroup>
Obviously, this only affects the build, not Visual Studio or it's intellisense. To hook that up, you need to follow the Trying Your Changes in Visual Studio guide in the Roslyn repo. You have to build one of the VSIX projects in the Roslyn solution. Running one of those projects launches an experimental instance of Visual Studio where you can play around with your changes.
M0sa's answer might work, however, that will only give you MSBuild enabled builds. If you also want to test it in VS, then you can follow Roslyn's own documentation. That page tell you how to replace the "intellisense" in Visual Studio (the VisualStudioSetup bullet), and the Ctrl-Shift-B "Build Solution" to actually run your solution (the CompilerExtension).
If you just want to try out your build of Roslyn, you can do that by opening Roslyn.sln in VS15 and then running the Roslyn project (with or without debugging). It will start a new instance of VS15, which uses your build of Roslyn.

"nunit.framework.dll" could not be found

I am following the NUnit tutorial here.
My source files live in the folder C:\Users\Me\Documents\Visual Studio 2015\Projects\NUnitTest\NUnitTest. My NUnit DLL lives in the folder C:\Program Files (x86)\NUnit.org\framework\3.2.0.0\portable\nunit.framework.dll. I am certain that these paths are correct.
To compile the source file AccountTest.cs into a DLL, I ran the following commands:
cd C:\Users\Me\Documents\Visual Studio 2015\Projects\NUnitTest\NUnitTest
C:\Users\Me\Documents\Visual Studio 2015\Projects\NUnitTest\NUnitTest>csc /target:library /out:AccountTest.DLL /r:C:\Program Files (x86)\NUnit.org\framework\3.2.0.0\portable\nunit.framework.dll AccountTest.cs
However, I see these error messages:
error CS2001: Source file 'C:\Users\Me\Documents\Visual Studio 2015\Projects\N
UnitTest\NUnitTest\Files' could not be found.
error CS2001: Source file 'C:\Users\Me\Documents\Visual Studio 2015\Projects\N
UnitTest\NUnitTest\(x86)\NUnit.org\framework\3.2.0.0\portable\nunit.framework.dl
l' could not be found.
Any advice?
EDIT: I didn't forget to add a reference to NUnit inside of my solution. I also included the appropriate using statement.
It is because you did not quote the path to the NUnit assembly when you compiled from the command line. It should be this,
csc /target:library /out:AccountTest.DLL /r:"C:\Program Files (x86)\NUnit.org\framework\3.2.0.0\portable\nunit.framework.dll" AccountTest.cs
You should also know that the NUnit Console cannot run tests using the portable version of the framework at the moment. To do that, you need to create a self-executing test assembly using NUnitLite. For now, it would be easier for you to just use the .NET 4.5 version of the framework.
Is there any reason you are compiling at the command line? Visual Studio Community Edition is free and will handle compiling for you. If you are not on Windows, MonoDevelop is another good option.
Have you added a reference to your Solution?
right click Solution
hover over add
click reference
search for Nunit reference and add it
Also, make sure that you have added a using statement at the top of your project on all classes

Categories

Resources