How adapt extension to Visual Studio 2019? - visual-studio-extensions

I read that adapting of extension for VS 2019 is quite easy - https://devblogs.microsoft.com/visualstudio/visual-studio-extensions-and-version-ranges-demystified/#.
But I got an error if I do all the actions from the post:
It's not possible to install because there is no following links:
Microsoft.VisualStudio.Component.CoreEditor.
The author of the post shows the exactly same row when he adapts his extensions:
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,)" />
So it seems that this prerequisite was not a problem for him.
My updated extension.vsixmanifest is:
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011">
<Metadata>
<Identity Id="PowerQuerySDK.Microsoft.30831070-f420-4649-a031-6f679996b182" Version="1.0.0.20" Language="en-US" Publisher="Microsoft" />
<DisplayName>Power Query SDK</DisplayName>
<Description xml:space="preserve">A Power Query language service for Visual Studio</Description>
<License>Microsoft Power Query SDK - Pre-Release or Evaluation Use Terms.rtf</License>
<Icon>dataconnector_128.png</Icon>
<PreviewImage>EATIcon.ico</PreviewImage>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[14.0,17.0)" />
<InstallationTarget Version="[14.0,17.0)" Id="Microsoft.VisualStudio.Pro" />
<InstallationTarget Version="[14.0,17.0)" Id="Microsoft.VisualStudio.Enterprise" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" Version="[4.5,)" />
</Dependencies>
<Assets>
<Asset Type="Microsoft.VisualStudio.ProjectTemplate" Path="ProjectTemplates" />
<Asset Type="Microsoft.VisualStudio.ItemTemplate" Path="ProjectTemplates" />
<Asset Type="Microsoft.VisualStudio.VsPackage" Path="Dependencies\Microsoft.Mashup.Tools.VisualStudio.pkgdef" />
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Dependencies\Microsoft.Mashup.Tools.VisualStudio.dll" />
</Assets>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,)" />
</Prerequisites>
</PackageManifest>
Please could you say what may be the workaround for the problem?

I found the solution for the problem. It is in catalog.json file inside PowerQuerySdk.vsix file. You should change part of the file from:
"Microsoft.VisualStudio.Component.CoreEditor":"[15.0,16.0)"}
to:
"Microsoft.VisualStudio.Component.CoreEditor":"[15.0,17.0)"}
.
I didn't suspect that the mention of CoreEditor may be in this file. But obviously you should change the version of MSBuild to 17, just as you should do in extension.vsixmanifest, as it is described in the post of Mads Kristensen above.
Up to now all works fine for me :-).

I also ran into this issue while porting a Visual Studio Extension forward from 2017 to 2019.
The change was 2-fold:
Firstly updating the 'Installation Target' range in the 'vsixmanifest' file.
Secondly, updating the Prerequisite 'Microsoft.VisualStudio.Component.CoreEditor'
Below is an example of the Manifest file I changed.
Pull Request
Mads Kristensen's original Blog Post on forward porting Visual Studio Extensions from VS 2017 to VS 2019.

Related

How to create Nuget package with nested dependencies

I'm working on a .NET Core solution. For one of the projects within the solution, I need to build a Nuget package.
Project A has a reference to another project B in the solution, set up as a project reference. Project B has a dependency on a Nuget package C.
Now, when I create a Nuget package for A, it includes A.dll and B.dll but not C.dll
Can someone help me figure this out? How can I include all 3 .dlls?
Thanks,
Andy
You can certainly solve this by creating your own nuspec file. I am not sure how to do it within the context of the csproj file.
For example, with #csla we manage all our own nuspec files because there are so many moving parts.
Within a nuspec file you can list the specific files you want included, along with any package dependencies. So in your example it sounds like your nuspec would include the project A and B assemblies, so something like this:
<files>
<file src="..\..\bin\Release\netstandard\netstandard2.1\**\A.dll" target="lib\netstandard2.1" />
<file src="..\..\bin\Release\netstandard\netstandard2.1\**\B.dll" target="lib\netstandard2.1" />
</files>
And would declare the dependency to package C.
<dependencies>
<group targetFramework="netstandard2.1">
<dependency id="C" version="1.0.0" />
</group>
</dependencies>
You can see numerous examples in the #csla repo. Perhaps the closest (not using wildcards) is the Csla.Blazor.nuspec file.
See https://github.com/NuGet/Home/issues/3891 for the feature request for dotnet.exe pack to the nuget client team. There are workarounds and debates in that issue.
Thx, Rob Relyea, NuGet Client Team

NLog does not create log files on ASP.NET Core project

I am new to using NLog with ASP.NET Core, so I have followed the guide here:
https://github.com/NLog/NLog.Web/wiki/Getting-started-with-ASP.NET-Core-(project.json)
I have created the following nlog.config file at the root of the project directory:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Warn"
internalLogFile="c:\temp\internal-nlog.txt">
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<!-- define various log targets -->
<targets>
<!-- write logs to file -->
<target xsi:type="File" name="allfile" fileName="${basedir}\nlog-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}|${message} ${exception}" />
<target xsi:type="File" name="ownFile-web" fileName="${basedir}\nlog-own-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}| ${message} ${exception}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" />
<target xsi:type="Null" name="blackhole" />
</targets>
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile" />
<!--Skip Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" />
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
</nlog>
Inside a controller, I call a line like this one:
_logger.LogInformation("Entered CustomerRange method");
which returns the following in the output window in Visual Studio:
CustomerMgmtAPI.Controllers.CustomerController:Information: Entered CustomerRange method
However, the actual log files are never created by NLog. I was wondering if someone can point out the error in the NLog configuration here, since I have been reviewing the documentation of NLog for ASP.NET Core project and I can't find the error myself.
So the actual fix to the problem was the remove the first line from the nlog.config file:
<?xml version="1.0" encoding="utf-8" ?>
I remove this line and everything started working as expected. I also noticed that Visual Studio was giving me these errors when that line was present:
Invalid token 'Text' at root level of document.
Unexpected XML declaration. The XML declaration must be the first node in the document and no white space characters are allowed to appear before it.
It seems in this case that the NLog tutorial is broken, as I just took over this file from the sample for ASP.NET Core. I am using VS2017, so perhaps there is an incompatibility with this version of VS?
The dirty little secret about using NLog with ASP.NET Core is that you can configure and create logs just as you did in ASP.NET and ASP.NET MVC. You just use the regular NLog Nuget package like you normally would.
Just create an NLog.config in your root, etc. You don't even have to make any extra configurations in the config or elsewhere to get it to work. You just reference NLog in your class and then create a logger with the LogManager.
What this means is that you don't have all of the wireup in Program.cs etc.

Publish not transforming Web.config for Website project [duplicate]

It doesn't seem to be possible to change the Build Configuration of Visual Studio 2010 Website Projects (as opposed to Visual Studio Web Applications), and changing the Build Configuration is a key part of enabling Web.config transformations (it's not possible to change the configuration to anything except Debug).
How do I get Web.config transformations to work with Visual Studio 2010 Website projects if it's not possible to change the Build Configuration?
I'd prefer not to use entire an Web Application Project solution out of box.
My solution is to use the XmlTransform task defined in Microsoft.Web.Publishing.Tasks.dll directly (this task is the core of WebConfigTransformation)
This way it is flexible enough and does exactly what you expect it to do.
For example here is the WebSiteTransformator.csproj I'm using for transforming web.config.
Here also is an example of flexibility that is impossible to reach with original WebConfigTransformation: it takes web.Template.config, applies web.$(Configuration).config over it and writes web.config. This allows us to add web.config itself into ignore list in source control. It is still valid csproj to be referenced by website:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<OutputType>Library</OutputType>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<OutputPath>$(TEMP)\TransformWebConfig\bin</OutputPath>
<BaseIntermediateOutputPath>$(TEMP)\TransformWebConfig\obj\</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
<WebFolderName>$(SolutionDir)\MyWebSite\</WebFolderName>
</PropertyGroup>
<ItemGroup>
<Compile Include="Dummy.cs" />
</ItemGroup>
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="BeforeBuild">
<TransformXml Source="$(WebFolderName)Web.Template.config"
Transform="$(WebFolderName)Web.$(Configuration).config"
Destination="$(WebFolderName)Web.config" />
</Target>
</Project>
I found a pretty good blog post describing a solution to this here:
http://andrewtwest.com/2010/02/25/using-web-config-transformations-in-web-site-projects/
In short: create an empty project (as long as it is not another website project) in your solution that contains the website. The empty project will give you access to msbuild through its project file, which will allow you to perform transforms on your website web.config.
I used a slightly alternative approach. Still a bit of a hack, but I think a lot more straightforward. This worked for me, but obviously there are a lot of different configurations available so I can't guarantee it'll work for everyone. This revolves around the way that a website is first packaged up in to your AppData folder before being published...
Manually add a Web.Release.config file to the website and add the necessary transforms - obviously there's no 'Add Config Transform' option for websites, hence having to do this manually. Example Web.Release.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="MySetting" value="NewValue" xdt:Transform="Replace" xdt:Locator="Match(key)" />
</appSettings>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
Inside the website.publishproj file, ensure the configuration is set to Release:
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
Add the following to the very bottom of website.publishproj (just before </Project>):
<Target Name="AfterBuild">
<MakeDir Directories="$(PackageArchiveRootDir)\..\CSAutoParameterize\original" />
<TransformXml Source="Web.config" Transform="Web.$(ConfigurationName).config" Destination="$(PackageArchiveRootDir)\..\CSAutoParameterize\original\Web.config" StackTrace="false" />
</Target>
Create a publish profile in VS 2017 and then right click on the .pubxml profile in App_Data\PublishProfiles and select Add Config Transform.
See https://social.msdn.microsoft.com/Forums/vstudio/en-US/31f41991-abb2-41de-ad0b-c1379cc7c806/vs-2013-express-for-web-webconfig-transforms?forum=visualstudiogeneral&prof=required
As mentioned in Andriy's comment above, Solution wide build events definitely seems like a cleaner way to do this.
I am adding this as a separate answer, as it gets a little lost in the comment, but IMHO is the best answer. Props to Andriy K and Sayed Ibrahim.
If you would prefer not to need a Web.Template.config, I used this:
<PropertyGroup>
<_tempSourceFile>$([System.IO.Path]::GetTempFileName())</_tempSourceFile>
<_tempTransformFile>$([System.IO.Path]::GetTempFileName())</_tempTransformFile>
</PropertyGroup>
<Copy SourceFiles="$(ProjectDir)Web.config" DestinationFiles="$(_tempSourceFile)"/>
<Copy SourceFiles="$(ProjectDir)Web.$(Configuration).config" DestinationFiles="$(_tempTransformFile)"/>
<TransformXml Source="$(_tempSourceFile)"
Transform="$(_tempTransformFile)"
Destination="$(ProjectDir)Web.config"
StackTrace="false" />
Adapted from an answer here.

Flex 4.5.1 runtime ReferenceError: Error #1065: Variable ... is not defined

Ok, I need some help on this one. I upgraded from Flash Builder 4 to Flash Builder 4.5 and have switched my project to the 4.5.1 sdk. I use an ant script to build my project, so I modified it to use the appropriate flexTasks.jar, mxmlc, etc...
Now, if I start out with a blank bin-debug folder, then build and run the app everything works fine. However, if I then make a code change and build (without deleting the bin-debug) then run the app I get a runtime error:
ReferenceError: Error #1065: Variable ... is not defined.
at flash.display::MovieClip/nextFrame()
at mx.managers::SystemManager/deferredNextFrame()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\SystemManager.as:284]
at mx.managers::SystemManager/preloader_preloaderDocFrameReadyHandler()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\SystemManager.as:2633]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.preloaders::Preloader/timerHandler()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\preloaders\Preloader.as:515]
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
Again, if I delete the bin-debug folder and compile again it runs with no problems.
The variable it complains about is always a Class variable that points to an image file used as an icon. The code I use to create the var:
[Embed(source="/assets/icons/close-32x32.png")]
public var closeIcon:Class;
The file exists, and I verified that when it gives that error the file is in the bin-debug/assets/icons folder and the src/assets/icons/ folder.
After the error is thrown, if I hit the continue button in Flash Builder it then throws the same error again on the next Class variable pointing to an image file.
Any ideas? The delete/recompile takes several minutes, so obviously this is driving me mad.
Edit: Ant task that compiles in debug mode:
<target name="compile-debug">
<echo>Compile MXML</echo>
<mxmlc
file="${SRC_DIR}/${MAIN_SOURCE_FILE}"
debug="true"
optimize="false"
output="${DEBUG_DIR}/${APP_ROOT_FILE}"
append="true"
actionscript-file-encoding="UTF-8"
keep-generated-actionscript="false"
link-report="MyReport.xml"
maxmemory="2048m"
incremental="true">
<!-- Get default compiler options. -->
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<load-config filename="${FLEX_HOME}/frameworks/air-config.xml"/>
<!-- List of path elements that form the roots of ActionScript class hierarchies. -->
<source-path path-element="${FLEX_HOME}/frameworks"/>
<!-- Include Themes -->
<!-- NOTE: Spark theme required -->
<theme dir="${FLEX_HOME}/frameworks/themes/Spark/">
<include name="spark.css" />
</theme>
<theme dir="${FLEX_HOME}/samples/themes/spark_graphite/">
<include name="spark_graphite.css" />
</theme>
<!-- List of SWC files or directories that contain SWC files. -->
<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs" />
<include name="../bundles/{locale}" />
</compiler.library-path>
<!-- uncomment if you have external libs (swc files) -->
<library-path dir="${LIB_DIR}/riaspace/" append="true">
<include name="*.swc" />
</library-path>
<library-path dir="${LIB_DIR}/AlivePDF/" append="true">
<include name="*.swc" />
</library-path>
<library-path dir="${LIB_DIR}/coltware/" append="true">
<include name="*.swc" />
</library-path>
</mxmlc>
</target>
Where FLEX_HOME = < path to flash builder >/sdks/4.5.1
The answer is buried in the middle of Maxim's post that he referenced in a comment above:
--> Try turning off incremental compilation.
I had the same issue here with a simple mimeType='application/octet-stream' embed, and when reading Maxim's text this jumped out because I'd recently changed my custom build tools to use inremental compilation: "Embed sometimes fails during incremental compilation"
The result of this failure is that the .swf contains something like this:
<DefineBinaryData id='1' length='1024' />
which looks like it's empty, instead of this (from the working file):
<DefineBitsLossless2 id='1' encoding='base64'>
(.. in my case, 1024 bytes of base64-encoded data)
</DefineBitsLossless2>
(This solved it for me, so a big thank-you to Maxim. I hope it solves it for you too.)
I had the same problem, so I "Clean"ed the project and then re ran. It worked.
I have Flash Builder 4.7 and am using sdk 4.5.1A.
I was using Flash Player debugger version 15 before Christmas of 2014 and everything was working. I had Firefox set up as the default browser. However, in 2015, Adobe has a new player so I upgraded to version 16 and that's when I got the same problem. After much struggle, I found that the problem had to do with the new version of Firefox Flash player debugger. I had to switch the default browser to Internet Explorer and installed the Internet Explorer Flash player debugger. Prior to debugging, I had to clean and update first. Then everything worked again!

Flash Builder (Flex) ANT build and Debug

I'm trying to use ANT with Flash Builder 4 to compile and debug.
The compiling is the easy part but having trouble to get the debugger to work.
I want to use ANT to Debug SWF file inside Flash Builder, so that breakpoints, console traces and everything works as it should.
My script so far. Builds The *.as to *.swf and moves from bin-debug to deploy folder. How can I start a Flash Builder Debugger for the created SWF?
<target name="Compile level 1">
<antcall target="compile flex file">
<param name="file" value="GameOffice"/>
</antcall>
<antcall target="open player">
<param name="file" value="GameOffice.swf"/>
</antcall>
</target>
<target name="compile flex file">
<mxmlc file="${SRC_DIR}/${file}.as" output="${BUILD_DIR}/${file}.swf"
actionscript-file-encoding="UTF-8"
keep-generated-actionscript="true"
incremental="true"
static-link-runtime-shared-libraries="true"
show-actionscript-warnings="true"
failonerror="true"
debug="true"
optimize="false">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
<source-path path-element="${FLEX_HOME}/frameworks" />
<compiler.include-libraries dir="${basedir}/libs" append="true">
<include name="HelloThereLibGames.swc" />
<include name="HelloThereLibStructure.swc" />
<include name="HelloThereLibUtils.swc" />
</compiler.include-libraries>
<metadata description="Hello There Production">
<contributor name="Fredrick Bäcker" />
</metadata>
</mxmlc>
<copy todir="${DEPLOY_DIR}" file="${BUILD_DIR}/${file}.swf"/>
</target>
I did a 1 try one hit on google: http://blogs.4point.com/armaghan.chaudhary/2009/04/remote-debugging-using-flex-builder-ide.html
I do not get why you would want to build with ant inside flashbuilder. Seems like crossing the stream for water?
IMHO automated build scripts belong in CI environments like hudson. I consider it doing myself a favor, letting my development environment handle the fuzz of local builds and debugging.
Anyways, best of luck
Assuming you are working off a local web server, you can simply open the debug socket in Flash Builder by setting your debug launch config to a blank html page (eg. about:blank) and then opening your browser to your localhost (or whatever url you've set up).
In this case you would run the build with ant, hit debug to open the socket, then switch over to your web browser and load localhost.
I realise this answer is probably a little late, but better late than never!
Is pretty simple really when you know how. I did a blog entry on it a while back that should show you how:
http://blog.tiltdigital.com/flex/running-flash-builder-4-in-debug-mode-from-apache-ant/
Basically you just need to add an Ant Builder to Flash Builder 'Builders' properties in your project properties. You can then use that to compile/debug using your build script as you'd normally do using the Flash Builder Compiler/Debugger.

Resources