I've created a new class library project with the following startup class:
public class Startup
{
public void Configure(IAppBuilder app)
{
app.Run(ctx =>
{
ctx.Response.StatusCode = 200;
ctx.Response.ContentType = "text/plain";
return ctx.Response.WriteAsync("Hello from Owin");
});
}
}
I have the following packages installed:
<packages>
<package id="Microsoft.Owin" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Host.HttpListener" version="2.1.0" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="OwinHost" version="2.1.0" targetFramework="net45" />
</packages>
When I attempt to run owinhost.exe from /bin/debug I get the following error:
Error: System.EntryPointNotFoundException
The following errors occurred while attempting to load the app.
- No assembly found containing an OwinStartupAttribute.
- No assembly found containing a Startup or [AssemblyName].Startup class.
Do I need to do anything else to get OwinHost.exe to work with a class library project (I had the same issue with a Console application).
If you execute the OwinHost.exe without parameters, the method name needs to be Configuration, not Configure.
Also, execute owinhost.exe under the root path (A.K.A {projectDir}) and output the builds to /bin, not /bin/debug. Of course, these are configurable through switches to OwinHost.exe but this is what it needs if you wanna run it w/o any switches.
More in depth explanation is available here: OWIN Startup Class Detection and here: Good Old F5 Experience With OwinHost.exe on Visual Studio 2013
Related
When I publish my ASP .NET Core (v.2.2) web application on a IIS-server it throws an exception on this line:
Directory.EnumerateFiles(_environment.ContentRootPath + #"/Pages/API")
The exception:
An unhandled exception has occurred while executing the request.
Could not find a part of the path 'C:\Release\MySite\Pages\API'.
System.IO.DirectoryNotFoundException at
System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String
path, Boolean ignoreNotFound)
When I look inside the published folder there is no API folder, but should it not be inside of my website dll? Or can I not use relative or absolute paths to find files in my web project when I publish it on ISS?
Note: The pages in folder API have Build Action : content, and the code works without problem in development (with IIS-express).
For asp.net core, it will precompile views while publishing into Project.Views.dll. For Directory.EnumerateFiles, it only lists the real exist files in the disk.
For a solution, try to modify your project.csproj to add <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>.
Full
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
</ItemGroup>
</Project>
Recently, I tried to run a Theory test case with ClassData as test input. This is a completely normal behavior and it used to work in the past. The provided code works and I can easily run all tests in Visual Studio 2017 (15.9.2) with xunit 2.1 to 2.4.1 and Resharper 2018.2.3.
The Problem: When I try to debug a Theory test, the debugger starts start but stops before stopping my breakpoint in the Theory test case. Resharper shows an error "Unable to find any matching test cases". As far as I could reproduce this error, it only happens when I debug a Theory test case which uses a class (not a primitive type) as T in TheoryData.
TestMethod_StringClassData: Uses StringClassData with TheoryData of type string.
TestMethod_CultureInfoClassData: Does not step into the test case when trying to debug it. The only difference here is, that the test parameter is not a string, but a CultureInfo object.
Test cases to reproduce the error:
public class UnitTest1
{
[Theory]
[ClassData(typeof(StringClassData))]
public void TestMethod_StringClassData(string cultureInfo)
{
}
[Theory]
[ClassData(typeof(CultureInfoClassData))]
public void TestMethod_CultureInfoClassData(CultureInfo cultureInfo)
{
}
public class StringClassData : TheoryData<string>
{
public StringClassData()
{
this.Add("de");
}
}
public class CultureInfoClassData : TheoryData<CultureInfo>
{
public CultureInfoClassData()
{
this.Add(new CultureInfo("de"));
}
}
}
Update 1:
If I create a new VS2017 csproj with Microsoft.NET.Test.Sdk and select TargetFramework netcoreapp2.1, everything works fine again! If I select TargetFramework net47, no more xunit Theory debugging is possible.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
</ItemGroup>
</Project>
I need to make a windows installer which enables (installs) IIS on windows.
When I run the .msi file, it runs without any give any however, IIS does not get enabled(installed) when I go to Program and Features/Turn Windows Feature on off, it does not get installed
Here is my wxs file:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="IISInstaller" Language="1033" Version="1.0.0.0" Manufacturer="Company" UpgradeCode="21ece05f-bf5c-4f97-850e-cb7cef2bf65e">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Property Id="QtExec64CmdLine" Value='"[WindowsFolder]Sysnative\dism.exe" /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-WebServer
/FeatureName:IIS-WebServerRole /FeatureName:IIS-RequestFiltering /FeatureName:IIS-Security
/FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ASPNET /FeatureName:IIS-ISAPIExtensions
/FeatureName:IIS-ISAPIFilter /FeatureName:IIS-DefaultDocument /FeatureName:IIS-HttpErrors /FeatureName:IIS-StaticContent
/FeatureName:IIS-HttpLogging /FeatureName:IIS-RequestMonitor /FeatureName:IIS-HttpCompressionStatic
/FeatureName:IIS-HttpCompressionDynamic /FeatureName:IIS-RequestFiltering /FeatureName:IIS-WindowsAuthentication'/>
<CustomAction Id="SilentLaunch" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="immediate" Return="check" />
</Product>
</Wix>
even when I change the value in the property to run a simple command to make directory
mkdir test
it does not work either.
Could you please help me what is the problem?
Thanks
Two potential problems:
You have declared the custom action but you haven't put it in a sequence by declaring where it's going to run and what conditions apply. So it didn't run.
Step 2 is missing: http://wixtoolset.org/documentation/manual/v3/wixdev/extensions/authoring_custom_actions.html
After you've done that, the custom action is marked immediate which is usually an error because changes to the system should be done in deferred mode, and immediate custom actions don't run elevated.
I am using the Azure 2.5 SDK to upload a cspkg + cscfg to create a new web role deployment in Azure. When I do, I see the following error with status BadRequest.
{"BadRequest : The file provided is not a valid service package. Detailed error code: {0} Invalid application runtime - a runtime component is missing:/base/x64/IISConfigurator.exe."}
Where {0} is the role/project name.
However, when I inspect the contents of my cspkg file, the base/x64 directory DOES contain IISConfigurator.exe.
I also notice that the RoleModel.xml file has been modified by packaging to contain an IISConfigurator.exe task as follows:
<RoleModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="CacheExtension" version="2.5.6496.10" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<Startup>
<Task commandLine="IISConfigurator.exe" executionContext="elevated" relativePath="base\x64">
<Environment>
<Variable name="_IISCONFIGURATOR_SETUP_URL_REWRITE_" value="true" />
<Variable name="_IISCONFIGURATOR_CLEAN_SERVER_ONSTARTUP_" value="true" />
<Variable name="RdModuleName" value="IISConfigurator" />
</Environment>
</Task>
So my question is: What is the real cause of this error message?
Additional possible clues:
My RoleModel.xml in the cspkg also contains:
<Property name="TargetFrameworkVersion" value="v4.5.1" />
<Property name="RoleType" value="Web" />
<Property name="Configuration" value="Debug" />
<Property name="Platform" value="AnyCPU" />
<Property name="SetConfiguration" value="Configuration=Debug" />
<Property name="SetPlatform" value="Platform=AnyCPU" />
<Property name="RoleTargetFramework" value="v4.5.1" />
<Property name="TargetRuntimeVersion" value="v4.0" />
Tim, we have seen this issue only twice, and it was with developers who had upgraded to SDK 2.5.1. We were never able to reproduce the problem and we didn't find the root cause before those developers uninstalled the Azure SDK and reinstalled SDK 2.5 which caused the issue to go away.
Can you try uninstalling and reinstalling the Azure SDK? You could also try SDK 2.6 which was just released.
I had this issue using the Azure 2.9 SDK.
I started looking in control panel and was seeing what appeared to be some double installs.
I uninstalled all 2.9 Azure components from my PC, and reinstalled the required ones. Then it all worked for me.
I have been following this post about how to build a VSIX project that will add some custom MVC project types:
http://www.asp.net/mvc/tutorials/mvc-4/custom-mvc-templates
I also want to include some additional Nuget packages, so I was following this page from Nuget, but it seems to be for VS2010 and I'm working in 2012.
I have the project building, and everything works peachy on my machine. The install works, the new project type appears, and when I create a new project of this type, everything works perfectly.
However, when I send the installer to a coworker, things break. The installer works, they see the new project type, but when creating the project he gets error messages about not being able to install any of the packages in the extension node. I've confirmed the Product Id of the extension is correct (I intentionally malformed it in the .vstemplate file during testing and it gave an entirely different error). I've added the packages to the extension manifest, but it doesn't seem to make a difference. I've also confirmed the .nupkg files get deployed to %ProgramFiles(x86)%\Microsoft Visual Studio 11.0\Common7\IDE\Extensions.
Any suggestions on what to do?
Custom Project's .vstemplate section
<WizardExtension>
<Assembly>NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>NuGet.VisualStudio.TemplateWizard</FullClassName>
</WizardExtension>
<WizardData>
<packages repository="registry" keyName="AspNetMvc4VS11" isPreunzipped="true">
<package id="EntityFramework" version="5.0.0" skipAssemblyReferences="true" />
<package id="jQuery" version="1.8.2" />
<!-- snip -->
</packages>
<packages repository="extension" repositoryId="SampleExtensionId">
<package id="Unity" version="3.0.1304.0" targetFramework="net45" />
<package id="Unity.WebAPI" version="0.10" targetFramework="net45" />
<!-- snip -->
</packages>
</WizardData>
source.extension.vsixmanifest Asset tags
<Assets>
<Asset d:VsixSubPath="ProjectTemplates\CustomMVCTemplate" etc/>
<Asset Type="Unity.3.0.1304.0" Path="Packages\Unity.3.0.1304.0.nupkg" />
<Asset Type="Unity.WebAPI.0.10" Path="Packages\Unity.WebAPI.0.10.nupkg" />
<!-- snip -->
</Assets>
File Structure
Extension Project
Packages
NugetPackage 1
NugetPackage 2
etc
ProjectTemplates
CustomMVCTemplate
<custom project files>
source.extension.vsixmanifest
I've made a step by step video on how to make a VSIX that auto downloads nuget packages.
http://www.youtube.com/watch?v=_ZvsFz41H-E
Since there are many steps and I never wrote them down, I won't type them here. I've definitely tested my VSIX package on other people's machine and it worked so hopefully this will work for you.
To download latest versions of NuGet packages plus all their dependencies add a following class to your vsix:
public class MyProjectWizard : IWizard
{
IEnumerable<string> _packages;
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
{
if (customParams.Length > 0) {
var vstemplate = XDocument.Load((string)customParams[0]);
_packages = vstemplate.Root
.ElementsNoNamespace("WizardData")
.ElementsNoNamespace("packages")
.ElementsNoNamespace("package")
.Select(e => e.Attribute("id").Value)
.ToList();
}
}
public void ProjectFinishedGenerating(Project project)
{
var componentModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel));
var _installer = componentModel.GetService<IVsPackageInstaller2>();
foreach (var package in _packages) {
_installer.InstallLatestPackage(null, project, package, false, false);
}
}
}
And then use following in vstemplate:
<WizardExtension>
<Assembly>MyProjectWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=22c2a1a5fa7b6905</Assembly>
<FullClassName>MyProjectWizard.MyProjectWizard</FullClassName>
</WizardExtension>
Check out this link http://samritchie.net/2012/09/17/nuget-packages-in-vs2012-templates/ which helped me. However, I'm still running into the issue where all my references' paths are empty.
Note especially the following comment from the article linked above:
I spent a considerable period of time attempting to work out what the v2 equivalent of CustomExtension was, but to cut a long story short, you don’t need to make any changes to the .vsixmanifest — it’s enough to include all of the packages in the VSIX under a ‘Packages’ directory.