Comments (6)
Yes it supports webapi2.
I'm not sure the exact issue you are encountering - but depending on how you have converted it, you are probably missing the launchsettings.json file
from your properties directory.
Remove the ProjectExtensions
section and all the *IISExpress*
properties from the project. All of that is handled by launchsettings.json
.
Also, you don't need any ProjectCapability
entries. The ones supported/required are automatically applied by the SDK.
Look at the empty web sample for the minimum required.
https://github.com/CZEMacLeod/MSBuild.SDK.SystemWeb/tree/main/samples/ExampleEmptyWebApplication
There is also an Owin example here https://github.com/CZEMacLeod/OwinStaticFilesUsingCore - note that it was a small experiment to wrap the aspnetcore StaticFiles IContentTypeProvider into an Owin version due to some filetypes being missing in Owin. The references to Microsoft.AspNetCore
should not normally be used in this system.
Also Microsoft.CodeDom.Providers.DotNetCompilerPlatform is not automatically included by the SDK.
By default it is version 3.6.0. There are some issues with the older versions in this scenario which are resolved in this version.
You can move to a newer version by setting the property <MicrosoftCodeDomProvidersDotNetCompilerPlatform_Version></MicrosoftCodeDomProvidersDotNetCompilerPlatform_Version>
You may need to adjust the system.codedom section of your web.config to match the assembly version:
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
I doubt you need most of the Reference
items either. System.Web is automatically included by the SDK, and System, and System.Drawing are included by the base SDK.
You also (unlike in the original packages.config or legacy project format) do not need to include the complete hierarchy of packages (unless you want to use a newer version of a referenced package).
Including Microsoft.AspNet.WebApi
will include Microsoft.AspNet.WebApi.WebHost
which will include Microsoft.AspNet.WebApi.Core
which will include Microsoft.AspNet.WebApi.Client
which will add the framework reference to System.Net.Http
as well as Newtonsoft.Json
You might want to include the Newtonsoft.Json
package directly to use a newer version - e.g. 12.0.3 or 13.0.1. See the ExampleFullWebApplication for more information.
I recommend playing with the example templates which are available for c# and vb as either empty or a full stack to understand more.
You also appear to have misspelt Microsoft.AspNet.WebApi.Own
- it should be Microsoft.AspNet.WebApi.Owin
and as far as I can remember you should only have 1 of Microsoft.AspNet.WebApi.Owin
or Microsoft.AspNet.WebApi.WebHost
depending on whether you are running WebAPI2 directly on System.Web or under Owin, regardless of whether Owin is selfhosted (Microsoft.Owin.SelfHost
) or running under System.Web (Microsoft.Owin.Host.SystemWeb).
I created a MVP of WebAPI2 in Owin on MSBuild.SDK.SystemWeb here - https://github.com/CZEMacLeod/WebAPI2-Owin
Hope this helps.
from msbuild.sdk.systemweb.
@CZEMacLeod This is wonderful work, thank you. Far above and beyond my expectations. I'm still getting
"Unable to run your project. The "RunCommand" Property is not defined."
There's a workaround here that I'll try: dotnet/sdk#833
from msbuild.sdk.systemweb.
Interestingly; what ended up fixing it was going into the project debug settings (through "properties" in visual studio) and ensuring the appropriate start up options were chosen. For whatever reason they were all blanked out and it wasn't picking it up from the launchSettings.json.
from msbuild.sdk.systemweb.
@gortok Great that you found a solution. My testing showed the RunCommand
error shows if the launchSettings.json
file is missing (or corrupted).
I'm guessing it was either in the wrong location, had a spelling mistake, or had bad content - all easily done.
I might try and add some more examples to the project here, and possibly extend the templates with more options, maybe to more closely match the options for the built-in ASP.Net 4 Web Application templates.
from msbuild.sdk.systemweb.
Yea, Once I fixed everything via the 'properties' tab debugging worked just fine.
@CZEMacLeod One issue I'm running into now is when I run Build -> Publish <ProjectName>
, I get the following error:
It is an error to use a section registered as allowDefinition='MachineToApplication' Beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
I also receive this error when trying to publish in Azure Devops On-Premise.
From what I read this is caused by an intermediate directory obj
containing the web config as well as the bin directory; but I'm unclear on how to resolve the issue.
from msbuild.sdk.systemweb.
@gortok Regarding Publish - I don't think there is any good solution to publish from within VS.
I noticed that your project file had includes for Microsoft.NET.Sdk.Publish
which should not be used with this SDK.
The original publish mechanism for ASP.NET4 Web Application Projects does work though if you invoke it from the command line.
There is some discussion of this in issue #12.
msbuild "path\to\your\solution.sln" /t:rebuild ^
/p:Configuration=Release ^
/p:DeployOnBuild=True ^
/p:DeployDefaultTarget=WebPublish ^
/p:WebPublishMethod=FileSystem ^
/p:DeleteExistingFiles=True ^
/p:publishUrl="path\to\your\output\folder"
If you create the publish profiles on a legacy project then copy them into your project, they should work.
msbuild /t:Rebuild /p:DeployOnBuild=true /p:PublishProfile=FolderProfile.pubxml
Note that I would recommend that you always do a nuget restore
command before.
This should also work with CI/CD e.g. Azure DevOps.
I'm closing this here - if you want to open a specific issue regarding publish, open a new issue.
from msbuild.sdk.systemweb.
Related Issues (20)
- Environment-specific Web.config files do not end up in a deployment package HOT 2
- GenerateBindingRedirects task failed unexpectedly with System.UnauthorizedAccessException HOT 8
- Add support for Central Package Management HOT 2
- Provide `CommandLineArgsForDesignTimeEvaluation`? HOT 4
- AutoGenerateBindingRedirects causes output xml attributes to change order randomly HOT 1
- Central Package Management - Default Package Restore Failure HOT 9
- "ASP.NET Core Module is required" when running in Visual Studio HOT 5
- MSBuild.SDK.SystemWeb/4.0.82 projects do not load in Visual Studio 2022 17.5.0 HOT 10
- Setting RoslynToolPath to allow ASPX compilation with newer language versions HOT 8
- Launch Profiles editor no longer works in the latest versions of Visual Studio (17.5+)
- MSBuild.SDK.SystemWeb.RazorLibrary does not support GeneratedBindingRedirectsAction feature
- Microsoft.CodeDom.Providers.DotNetCompilerPlatform should use the latest version dependant on the target framework version HOT 1
- error : Could not open Source file: Could not find file 'Web.config;Web.config' HOT 1
- IIS Express profile launchSettings.json does not add environment variables in the iisexpress.exe process HOT 5
- Configuration-specific Web.configs added to project even if they don't exist
- GenerateBindingRedirects task emits warning without code - unable to suppress HOT 3
- Broken intellisense and aspnet warnings on WebForms projects HOT 26
- VsCode's new C# DevKit fails to launch HOT 7
- Auto added aspnetcore handler and "module" HOT 2
- Add support for autogenerated binding redirects that are not source controlled HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msbuild.sdk.systemweb.