Giter Site home page Giter Site logo

czemacleod / msbuild.sdk.systemweb Goto Github PK

View Code? Open in Web Editor NEW
143.0 10.0 8.0 633 KB

This MSBuild SDK is designed to allow for the easy creation and use of SDK (shortform) projects targeting ASP.NET 4.x using System.Web.

License: MIT License

C# 28.17% Visual Basic .NET 40.67% CSS 4.73% ASP.NET 0.96% HTML 18.10% PowerShell 7.37%
sdk dotnet c-sharp aspnet dotnetframework aspnet4 visual-basic msbuild-sdk hacktoberfest

msbuild.sdk.systemweb's People

Contributors

czemacleod avatar eeparker avatar leusbj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msbuild.sdk.systemweb's Issues

Configuration-specific Web.configs added to project even if they don't exist

Upon upgrading to the newest version (4.0.88), I found that Web.Debug.config/Web.Release.config were showing up as items with a ContentType of None in my project despite them not existing on disk:

image

In addition to showing in Solution Explorer, they also get added as pending changes to TFVC. (Probably not an issue with Git.)

I assume this was added by #44. I tried fixing the SDK but couldn't figure out the correct MSBuild incantation to add an Exclude attribute.

As a workaround I have explicit Remove items in my .csproj for them.

Visual Studio 2019 (v16.9.4) becomes unresponsive when marking MVC views as content when the Views directory contains a large number of files

Hello!

I've been using MSBuild.SDK.SystemWeb v4.0.47 in one of our ASP.NET projects running in .NET Framework 4.8, and although I had to mark the ~/Views, ~/Content, and ~/Scripts directories as Content, the migration to the SDK-style project format was successful.

I have another project which contains a very large amount of MVC views in the ~/Views directory; the csproj is now around 20.000 lines long and around 2 MiB in size.

I have a team of 6 to 8 people working in this project on a daily basis. Because of the large file size of the csproj, and the fact that it changes so frequently (usually around 10 times per day - that means around 10 commits per day that change this file), I've decided to track this file in Git LFS.

Because of the frequent changes, we constantly get merge conflicts which need to be resolved manually.

Merging the Git LFS tracked csproj file has worked in the past, but since me and some of my team members upgraded to Visual Studio v16.9 (I currently run v16.9.4), the Visual Studio merge tool doesn't download the Git LFS file prior to opening the merge tool. This means we only see the pointers to the Git LFS tracked files in the merge tool, not the file's content itself.

So, I wanted to solve this problem by migrating to SDK-style project format. After that, merge conflicts should be rare (because of the file globbing capabilities).

The migration works, but... I need to mark a list of files as content, otherwise my MSBuild command used to publish the project (for deployment), doesn't include the files in the publish output.

So I added the following to my csproj:

  <ItemGroup>
    <ContentFiles Include="App_Code\**;Content\**;Scripts\**;_app_offline.htm;appsettings.json;engineConfiguration.config;Global.asax;NLog.config;robots.txt" />
    <ViewFiles Include="Views\**" />
    <None Remove="@(ContentFiles)" />
    <None Remove="@(ViewFiles)" />
    <Content Include="@(ContentFiles)" />
    <Content Include="@(ViewFiles)" />
  </ItemGroup>

When I added this to the csproj and load the project, Visual Studio 2019 becomes unresponsive. I guess this is because of the very large amount of files it is recursively iterating. Unfortunately, this is unworkable for my team.

Perhaps I can mark these files as content in a different way? Maybe you have some ideas?

Many thanks in advance for your help!!

Steven Volckaert

Provide `CommandLineArgsForDesignTimeEvaluation`?

It seems this is an MSBuild property to speed up design-time evaluation.

And it seems this is now mandatory in Version 17.5.0 Preview 3.0. I get the following exception, and the project fails to fully initialize:

=====================
1/19/2023 11:44:21 AM
LimitedFunctionality
Microsoft.VisualStudio.LanguageServices.ProjectSystem.InvalidProjectDataException: Property 'CommandLineArgsForDesignTimeEvaluation' is required.
   at Microsoft.VisualStudio.LanguageServices.ProjectSystem.EvaluationData.GetRequiredPropertyValue(String name)
   at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.CPS.CPSProjectFactory.<CreateProjectContextAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.LanguageServices.Workspace.<>c__DisplayClass39_0.<<OnEvaluationUpdateAsync>g__ProcessInitialEvaluationDataAsync|1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
   at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>g__Action|0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )

I'm not sure if this is a bug on MS's end, given that it's a preview, but maybe we should set this property regardless.

Broken intellisense and aspnet warnings on WebForms projects

After migrating our main WebForms projects to use this SDK, we noticed that the intellisense on aspx files (and any others such as ascx, etc) stopped working properly. Additionally, on each opened file, an error is indicated like this at the very first line:

image

Autocomplete doesn't show normal asp: controls as well:

Standard SDK
image image

I tried deleting the contents in the %LocalAppData%\Microsoft\VisualStudio\[Version Number]\ComponentModelCache folder and restarting Visual Studio. When I do that, intellisense starts working for a bit, but after a few seconds (not doing anything in VS, just time based apparently), intellisense just stops working again.

To ensure this wasn't something particular to our project, I proceeded to create a brand new WebForms project using the standard VS template. I then performed the same conversion steps that we did on our real project on this minimal template, and I started observing the exact same behavior.

After the conversion, I attempted adding the EnableWebFormsDefaultItems msbuild flag (which I was unaware of) as well as tried using different versions of the DotNetCompiler (when we migrated our own project, we used the ExcludeSDKDefaultPackages flag).

Is this a known issue? How do I fix it?

For reference, here is a solution with 2 projects from the standard template: 1 converted, and the other standard.

WCF projects supported?

Found this SDK when trying to migrate a WCF project to sdk-style csproj file format.
Getting things to compile, but it complains about missing RunCommand element.

Is this scenario supported and I'm missing something or am I expecting too much ๐Ÿ˜…

Add support for Central Package Management

The release of NuGet 6.2.0, released with Visual Studio 2022 17.2, makes it possible to manage the versions of package references centrally in a single (or multiple, if one would wish) Directory.Packages.props file.

See Central Package Management (CPM) on Microsoft Docs.

I've been migrating some of our projects to use CPM. Today I tried to migrate our first Sdk="MSBuild.SDK.SystemWeb/4.0.82" project, but I'm getting a NU1008 error:

Projects that use central package version management should not define the version on the PackageReference items but on the PackageVersion items: Microsoft.CodeDom.Providers.DotNetCompilerPlatform;Microsoft.Net.Compilers.Toolset.

I presume MSBuild.SDK.SystemWeb would need to be updated to support this scenario?

Basically, when a Directory.Packages.props file is defined / used, the Version attribute on packages Microsoft.CodeDom.Providers.DotNetCompilerPlatform and Microsoft.Net.Compilers.Toolset should either be removed or be updated to VersionOverride.

Could this be considered for a future, perhaps for the next release?

For the meantime, I could quite easily workaround this issue by setting property ExcludeASPNetCompilers to true:

<PropertyGroup>
  <ExcludeASPNetCompilers>true</ExcludeASPNetCompilers>
</PropertyGroup>

So supporting CPM is by no means an urgent feature request.

Thank you!

Add container support?

This is probably something that should be posted to the Visual Studio Team... But maybe someone here can shed some light on this?

I have tried to get container support running on a project created with this sdk, but it doesn't seem to work.
(See here for the official docs on this container support)

I have added a package reference to the container tools:

<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.13" />

I have added a Dockerfile and a .dockerignore file.

I have added a profile to the launchsettings:

"Docker": {
  "commandName": "Docker",
  "launchBrowser": true,
  "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
  "publishAllPorts": true,
  "useSSL": true
}

But when I try to debug or run the project using that profile, I get an error message "the project doesn't know how to run the profile Docker":

image

Launch Profiles editor no longer works in the latest versions of Visual Studio (17.5+)

The Launch Profiles UI is included from Microsoft.Web.Designtime.targets which isn't included by this SDK. The UI pages are now also included in the VS install and override the SDK.
Not all properties are applicable to ASP.NET V4.x anyway, nor are all the profile types (e.g. executable, or out of box hosting) so it makes sense to create our own version of this file and the associated XAML files.

This issue is to capture any missing settings and try and bring them into the new project property pages mechanism, as well as add the missing launch profiles.

It would be great to capture the main project properties into the project settings, not least that descriptions can be added and there would be a central location for any such properties.

Currently would like to add all the main properties defined in each SDK, especially the common ones.

  • ExcludeSDKDefaultPackages
  • ApplySDKDefaultPackageVersions
  • GeneratedBindingRedirectsAction
  • MvcBuildViews
  • EnableWebFormsDefaultItems
  • SetRoslynToolPath
  • OverwriteAppConfigWithBindingRedirects

It would also be great to add a versions section to handle

  • MicrosoftNetCompilersToolset_Version
  • MicrosoftCodeDomProvidersDotNetCompilerPlatform_Version
  • RazorGeneratorMSBuild_Version
  • RazorGeneratorMVC_Version
  • MicrosoftAspNetMvc_Version

Support for C# 10?

I'm using C# 10 in my ASP.NET WebApplication (<LangVersion>10</LangVersion>). Using this SDK it seems this is not possible:

Invalid option '10' for /langversion. Use '/langversion:?' to list supported values.

Is there a way to make this work? FWIW I am building other libraries against .NET Framework 4.8 with C# 10.

CSHTML files in the App_Code directory are not loaded by IntelliSense

Hello!

I'm in the process of migrating one of our ASP.NET projects running in .NET Framework 4.8, to the SDK-style project format. I'm using MSBuild.SDK.SystemWeb v4.0.47 on Visual Studio v16.9.5.

This project has some CSHTML files in the App_Code directory; they contain reusable Razor helpers (@helper declaration) and functions (@function declaration).

When I open an MVC view (also a CSHTML file) which uses one of these helpers or functions, IntelliSense shows an error, saying it cannot find the helper. When I open the CSHTML file that contains the helper code, however, the error disappears.

Also, if I run the ASP.NET compiler (using the <AspNetCompiler/> MSBuild task) post-build, it reports no errors.

It seems like IntelliSense doesn't load the CSHTML files in the App_Code directory until the files are loaded manually. I've declared these files as Content in the project file as follows:

image

Perhaps these files need some additional properties in the project file (.csproj) to be successfully loaded by IntelliSense?

Alternatively: Can I declare the Razor helpers and functions in code, instead of in CSHTML? I haven't found out yet how I could do this.

Many thanks in advance for your ideas!

Cannot add Controller from Visual Studio context menu

Attempting to do so shows an alert with the message "There are no scaffolders supported for this item."

Steps to reproduce:

  1. Right-click the Controllers folder
  2. Select Add -> Controller...

Workaround:

  1. Add -> New Item
  2. Create a plain C# class
  3. Change the class to a controller manually

"ASP.NET Core Module is required" when running in Visual Studio

Steps to reproduce

  • mkdir SystemWeb
    cd SystemWeb
    dotnet new systemwebfull
    
  • Open SystemWeb.csproj in Visual Studio Community 2022
  • Start Debugging (F5)

What happens

Visual Studio now shows this error message: "The ASP.NET Core Module is required to host ASP.NET Core projects in IIS Express and does not appear to be installed. Try repairing Visual Studio to correct the problem."

When I try to run the project in Rider, I need to disable the Core Module by removing the following from applicationhost.config.

<add name="AspNetCoreModuleV2" image="C:\Program Files\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll" />

In Rider I can then run the project in IIS Express, but not debug it. The debug button becomes greyed out, so it's probably trying to start something or wait on something that doesn't happen.

What should happen

How can I run/debug the project with Visual Studio, and debug it with Rider?

Update

For Rider, there's a workaround documented here. Not ideal, but debugging works. I think that with Visual Studio's launch profiles one can achieve the same in Visual Studio.

Central Package Management - Default Package Restore Failure

When using Central Package Management, the default package restores fail if an explicit PackageVersion does not exist for the dependent packages the SDK is using.

e.g., I have an explicit PackageVersion set for:

  • Microsoft.AspNet.Mvc
  • RazorGenerator.Mvc
  • Microsoft.CodeDom.Providers.DotNetCompilerPlatform

However, I get the error for the two packages the SDK uses that I did not set references for.

  • Microsoft.Net.Compilers.Toolset
  • RazorGenerator.MsBuild

error NU1010: The PackageReference items Microsoft.Net.Compilers.Toolset;RazorGenerator.MsBuild do not have corresponding PackageVersion.

It looks like there needs to be additional checks to see if there is an existing PackageVersion defined for each dependent package.

Setting RoslynToolPath to allow ASPX compilation with newer language versions

Hey @CZEMacLeod! ๐Ÿ‘‹๐Ÿป

Thanks for stepping up and creating this amazing SDK ๐Ÿ™๐Ÿป

What do you think about setting RoslynToolPath in the SDK to allow the Roslyn CodeDOM provider to pick up the newer version of the compiler?

We've solved this by using GeneratePathProperty on PackageReference:

<ItemGroup>
  <PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="4.5.0" IncludeAssets="none" PrivateAssets="all" GeneratePathProperty="true" />
</ItemGroup>

And then setting RoslynToolPath:

<PropertyGroup>
  <RoslynToolPath>$(PkgMicrosoft_Net_Compilers_Toolset)\tasks\net472</RoslynToolPath>
</PropertyGroup>

This allows us to pass /langversion:11 to the CodeDOM provider and compile our ASPX-files using the newest version of the language.

Are you willing to accept a PR for this?

*.aspx not ignored for compilation in Release-Build

Hello,

we are currently migrating our ASP.NET Web Application from the old csproj format to the new SDK-Style Project format, but we are facing an issue with Release-Builds. It seems that *.aspx files can't be ignored for compilation by the
DefaultItemExcludes/ItemGroup directives. *.cs files for example are properly ignored.

The interessting thing is, that this happens only in Release-Builds. Debug-Builds aren't affacted.

I've attached a simple example solution.

Thanks in advance,
BR Michael
WebApplication2.zip

MSBuild.SDK.SystemWeb/4.0.82 projects do not load in Visual Studio 2022 17.5.0

I just upgraded my Visual Studio Professional 2022 instance to version 17.5.0, which was released on 21 February 2023.

My MSBuild.SDK.SystemWeb/4.0.82 projects do not load any more:

image

The log file shows:

===================
2023-02-23 09:17:20
LimitedFunctionality
Microsoft.VisualStudio.LanguageServices.ProjectSystem.InvalidProjectDataException: Property 'CommandLineArgsForDesignTimeEvaluation' is required.
   at Microsoft.VisualStudio.LanguageServices.ProjectSystem.EvaluationData.GetRequiredPropertyValue(String name)
   at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.CPS.CPSProjectFactory.<CreateProjectContextAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.LanguageServices.Workspace.<>c__DisplayClass39_0.<<OnEvaluationUpdateAsync>g__ProcessInitialEvaluationDataAsync|1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
   at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>g__Action|0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )
===================
2023-02-23 09:17:20
LimitedFunctionality
Microsoft.VisualStudio.LanguageServices.ProjectSystem.InvalidProjectDataException: Property 'CommandLineArgsForDesignTimeEvaluation' is required.
   at Microsoft.VisualStudio.LanguageServices.ProjectSystem.EvaluationData.GetRequiredPropertyValue(String name)
   at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.CPS.CPSProjectFactory.<CreateProjectContextAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.LanguageServices.Workspace.<>c__DisplayClass39_0.<<OnEvaluationUpdateAsync>g__ProcessInitialEvaluationDataAsync|1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
   at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>g__Action|0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )
===================

I could workaround this by adding property CommandLineArgsForDesignTimeEvaluation to my .csproj files (source):

<PropertyGroup>
  <CommandLineArgsForDesignTimeEvaluation>-langversion:$(LangVersion)</CommandLineArgsForDesignTimeEvaluation>
  <CommandLineArgsForDesignTimeEvaluation Condition="'$(DefineConstants)' != ''">$(CommandLineArgsForDesignTimeEvaluation) -define:$(DefineConstants)</CommandLineArgsForDesignTimeEvaluation>
</PropertyGroup>

GenerateBindingRedirects task emits warning without code - unable to suppress

I'm using /warnaserror msbuild switch to enable warnings as errors.
Currently, the messages about the bindings are warnings and the switch turns them into red error.

<Warning Condition="'$(GeneratedBindingRedirectsAction)' == 'Overwrite'"
             File="Web.config"
             Text="Generated Binding Redirects have been applied automatically to the Web.config. This warning will disappear on the next build." />

Proposals:

  1. Replace them with Messages
  2. Add custom Code to Warnings so people can suppress them.

Messages with high importance would be a better joice but let me know. I'm happy to send a PR with either change.

autogenerate binding redirects

I noticed when the solution has conflicting versions of nuget packages, instead of prompting as described here

it shows the error Warning MSB3276 Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190. <project name here> C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets 2182

which is odd because in the templates it looks like you already have that property set to true.

how did you generate the binding redirects seen in the samples?

GenerateBindingRedirects task failed unexpectedly with System.UnauthorizedAccessException

Hi. When auto-generating binding redirects, I'm receiving build errors if the web.config file is checked in to source control (TFVC, and is therefore readonly).

<Project Sdk="MSBuild.SDK.SystemWeb/4.0.81">
<PropertyGroup>
<!-- removed other stuff for brevity -->
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GeneratedBindingRedirectsAction>Overwrite</GeneratedBindingRedirectsAction>
</PropertyGroup>

This throws this error during the build process which goes away if I manually check out the web.config before building:

Severity Code Description Project File Line Suppression State
Error MSB4018 The "GenerateBindingRedirects" task failed unexpectedly.
System.UnauthorizedAccessException: Access to the path 'c:\path to my project\web.config' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at Microsoft.Build.Shared.FileUtilities.OpenWrite(String path, Boolean append, Encoding encoding)
at Microsoft.Build.Tasks.GenerateBindingRedirects.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() Internal C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 2422

Is there anyway to have the process checkout the web.config file automatically before overwriting the changes?

Thanks!

error : Could not open Source file: Could not find file 'Web.config;Web.config'

This issue is just to log this error in case anyone else encounters it:

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VisualStudio\v17.0\Web\Microsoft.Web.Publishing.targets(1552,5):
error : Could not open Source file: Could not find file 'C:\Project\Web.config;Web.config'. [Project.csproj]

This happened when a project was migrated to SDK-style, while keeping the explicit Content items.

Fix: Add <EnableWebFormsDefaultItems>false</EnableWebFormsDefaultItems> or remove the explicit items.

Thanks for building this package!

Unable to get Web API 2 to debug using MSBuild.SDK.SystemWeb

I have the following ASP.NET Web API 2 project set up that has been converted over to the Sdk style using the MSBuild.SDK.SystemWeb.

<Project Sdk="MSBuild.SDK.SystemWeb/4.0.79">
  <Import Sdk="Microsoft.NET.Sdk.Publish" Project="Sdk.props" />
  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <UseIISExpress>true</UseIISExpress>
    <Use64BitIISExpress></Use64BitIISExpress>
    <IISExpressSSLPort />
    <IISExpresAnonymousAuthentication>disabled</IISExpressAnonymousAuthentication>
    <IISExpressWindowsAuthentication>enabled</IISExpressWindowsAuthentication>
     <IISExpressUseClassicPipelineMode></IISExpressUseClassicPipelineMode>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>
  <ItemGroup>
    <ProjectCapability Include="Web" />
    <ProjectCapability Include="DotNetCoreWeb" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNet.Cors" Version="5.2.7" />
    <PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.7" />
    <PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
    <PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.7" />
    <PackageReference Include="Microsoft.AspNet.WebApi.Cors" Version="5.2.7" />
    <PackageReference Include="Microsoft.AspNet.WebApi.Own" Version="5.2.7" />
    <PackageReference Include="Microsoft.AspNet.WebApi.WebHost" Version="5.2.7" />
    <PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="2.0.1" GeneratePathProperty="true" />
    <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
    <PackageReference Include="Microsoft.Net.Http" Version="2.2.29" />
    <PackageReference Include="Microsoft.Owin" Version="4.0.1" />
    <PackageReference Include="Microsoft.Owin.Cors" Version="4.0.1" />
    <PackageReference Include="Microsoft.Owin.Host.SystemWeb" Version="4.0.1" />
    <PackageReference Include="Microsoft.Owin.Security" Version="4.0.1" />
    <PackageReference Include="Microsoft.Owin.Security.Jwt" Version="4.0.1" />
    <PackageReference Include="Microsoft.Owin.Security.OAuth" Version="4.0.1" />
    <PackageReference Include="Owin" Version="1.0" />
    <PackageReference Include="System.Buffers" Version="4.5.1" />
    <PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
    <PackageReference Include="System.Configuration.ConfigurationManager" Version="4.7.0" />
    <PackageReference Include="System.Memory" Version="4.5.4" />
    <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
    <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
    <PackageReference Include="System.Security.AccessControl" Version="4.7.0" />
    <PackageReference Include="System.Security.Permissions" Version="4.7.0" />
    <PackageReference Include="System.Security.Principal.Windows" Version="4.7.0" />
    <PackageReference Include="System.ValueTuple" Version="4.5.0" />
    <PackageReference Include="ValueInjecter" Version="3.1.3" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="System.Net" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Net.Http.WebRequest" />
    <Reference Include="System.Security" />
    <Reference Include="System" />
    <Reference Include="System.Web.Entity" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Web" />
    <Reference Include="WindowsBase" />
  </ItemGroup>
    <ProjectExtensions>
      <VisualStudio>
        <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
          <WebProjectProperties>
           <UseIIS>True</UseIIS>
           <AutoAssignPort>True</AutoAssignPort>
           <DevelopmentServerPort>56462</DevelopmentServerPort>
           <DevelopmentServerVPath>/</DevelopmentServerVPath>
           <IISUrl>http://localhost:56462/</IISUrl>
           <NTLMAuthentication>false</NTLMAuthentication>
           <UseCustomServer>False</UseCustomServer>
           <CustomServerUrl>
           </CustomServerUrl>
           <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
          </WebProjectProperties>
        </FlavorProperties>
      </VisualStudio>
    </ProjectExtensions>
  <Import Sdk="Microsoft.NET.Sdk.Publish" Project="Sdk.targets" />
</Project>

The problem I'm running into is when I try to debug (Debug -> Start New Instance), I get the following error:

Unable to run your project. The "RunCommand" property is not defined.

A few questions:

  1. Does MSBuild.SDK.SystemWeb support ASP.NET Web API 2 projects?
  2. If so, what am I missing in order to have it debug through Visual Studio?

Using Microsoft.Build.CentralPackageVersions causes a compile-time error

When centralizing all package references in a single file (see https://github.com/microsoft/MSBuildSdks/tree/main/src/CentralPackageVersions), using this project causes a compile-time error, as src/MSBuild.SDK.SystemWeb/Sdk/Sdk.targets defines a version for the 2 referenced packages.

Note that a work-around is simple, as one can define the property ExcludeASPNetCompilers and reference the 2 packages directly in one's own csproj.

`designer.cs` doesn't get generated for `aspx` files

def21c2 added WebForms files as Content. That's fine for publishing, but it doesn't update the .aspx.designer.cs file.

VS's properties on the old SDK just show Content as the Build Action, and there's no Custom Tool either, so I'm unsure how to reverse-engineer the behavior.

For example, if you insert this into a aspx file and wait for a moment:

                <asp:Label ID="Foo" runat="server" />

โ€ฆthen that'll generate this:

        /// <summary>
        /// Foo control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Label Foo;

I couldn't find anything like "generate ASP designer.cs from command line". Perhaps this entire toolchain predates MSBuild and therefore isn't available as a taskโ€ฆ

Visual Studio publish command does generate any output

In a MVC application generated using the project template, when I activate the Publish command with a Folder profile, the process ends without any error, but the output folder is empty. It seems that no Publish step is actually executed - build log:

Build started...
1>------ Build started: Project: Test.Mvc, Configuration: Release Any CPU ------
1>
1>Restore operation started...
1>
1>5 libraries restored in 1,36 seconds
1>Test.Mvc -> C:\Users\me\source\repos\Test\Test.Mvc\bin\Test.Mvc.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 0 failed, 0 skipped ==========

AutoGenerateBindingRedirects causes output xml attributes to change order randomly

Not sure this is the right repo to ask this, but I just changed one of our projects to use this SDK and set these properties:

<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <GeneratedBindingRedirectsAction>Overwrite</GeneratedBindingRedirectsAction>

When building the project it occasionally makes updates to the config that looks like this:

image

For some reason it changes the order of those attributes in the xml, but the order seems to be random or always opposite of the current xml. Some times publicKeyToken comes first, other times it's the culture attribute. The value of the attributes doesn't change.

Does this xml output come from this project or is it coming from an msbuild task/target?

Support Publish to IIS from withing Visual Studio using the GUI

<Project>
  <Import Sdk="Microsoft.NET.Sdk.Publish" Project="Sdk.props" />

  <ItemGroup>
    <ProjectCapability Include="DotNetCoreWeb" />
    <ProjectCapability Include="Web" />
  </ItemGroup>
  <Import Sdk="Microsoft.NET.Sdk.Publish" Project="Sdk.targets" />
</Project>

Add this to enable publish to IIS feature

App_GlobalResources should be content instead of embedded resource

According to dotnet/project-system#2670 (comment), resource files in the App_GlobalResources folder only work if they are built as Content, and will not work correctly if processed as an EmbeddedResource. This rule could be applied to the sdk include files so that it doesn't have to be done manually for all projects which make use of App_GlobalResources. An example solution that should be able to be placed in the import files is given in the comment, and included below.

<ItemGroup>
  <EmbeddedResource Remove="App_GlobalResources\*.resx" />
  <Content Include="App_GlobalResources\*.resx">
    <Generator>GlobalResourceProxyGenerator</Generator>
    <LastGenOutput>%(Filename).Designer.cs</LastGenOutput>
  </Content>
  <Compile Update="App_GlobalResources\*.Designer.cs">
    <DesignTime>True</DesignTime>
    <AutoGen>True</AutoGen>
    <DependentUpon>$([System.Text.RegularExpressions.Regex]::Replace('%(Filename)', '\.Designer$', '')).resx</DependentUpon>
  </Compile>
  <Compile Update="App_GlobalResources\*.Designer.vb">
    <DesignTime>True</DesignTime>
    <AutoGen>True</AutoGen>
    <DependentUpon>$([System.Text.RegularExpressions.Regex]::Replace('%(Filename)', '\.Designer$', '')).resx</DependentUpon>
  </Compile>
</ItemGroup>

I augmented the example to also include Designer.vb files, though, given that I have not used VB in a fairly long time, I'm not certain how the designer files work in this situation.

Unable to add a connected service: Connected Services component 'Microsoft WCF Web Service Reference Provider' throws an error

Hello!

I'm migrating one of our ASP.NET projects running in .NET Framework 4.8, to the SDK-style project format.

This service has a dependency to one WCF web service, an ASMX file to be more exact.

I'd like to regenerate the service proxy for this class, so I right-clicked the Connected Services node in Solution Explorer, and then selected Microsoft WCF Web Service Reference Provider. I've used this provider successfully in the past, in a class library project (also using the SDK-style project format), which targets .NET Framework 4.7.2 and .NET Standard 2.0.

In the ASP.NET project using MSBuild.SDK.SystemWeb/4.0.47 as an SDK, however, clicking the Microsoft WCF Web Service Reference Provider button gives an error, and the user interface doesn't load:

image

Any ideas? I'm running Visual Studio 2019 v16.9.5, which I installed this morning.

Fixing this issue is not urgent for me, as I managed to work around it by adding the connected service in a class library project targeting .NET Framework 4.8, which also uses the SDK-style project format. This project is added as a project reference to my ASP.NET project.

IntelliSense errors in Visual Studio 2022 (v17.0.1)

Hello!

We're using MSBuild.SDK.SystemWeb v4.0.49` in some of our ASP.NET MVC 5 projects, which are targeting .NET Framework 4.8,

My development team has let me know that when they open CSHTML files, they get IntelliSense errors like the one below.

image

I tried updating MSBuild.SDK.SystemWeb to the latest release (v4.0.63), but no luck. When running or debugging the application, there is no problem at all; everything seems to work.

Would anyone have some ideas on how to fix or workaround this?

In both VS 2019 and VS 2022, the default editor for CSHTML files is HTML Editor:

image

Also, when I open a CSHTML file, the following notification is displayed in the bottom-left corner of the screen:

image

And when I click the notfiication,Visual Studio takes me to the Language Client activation failures; exception details below:

Task Failed - Activating language client HtmlLanguageClient: HtmlLanguageClient failed to initialize.  Please report a problem via Help -> Send Feedback -> Report a Problem.  Status = Sending 'initialize' request.  Exception = StreamJsonRpc.ConnectionLostException: The JSON-RPC connection with the remote party was lost before the request could complete.
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__149.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__139`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.LanguageServer.Client.JsonRpcExtensionMethods.<SendMethodRequestAsync>d__1`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.LanguageServer.Client.RemoteLanguageClientInstance.<SendInitializeRequestAsync>d__101.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.LanguageServer.Client.RemoteLanguageClientInstance.<InitializeAsync>d__100.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.LanguageServer.Client.RemoteLanguageClientInstance.<InitializeAsync>d__100.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.ThreadingTools.<WithCancellationSlow>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.LanguageServer.Client.RemoteLanguageClientInstance.<ActivateLanguageClientAsync>d__107.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

You can find the csproj of one of the projects below:

<Project Sdk="MSBuild.SDK.SystemWeb/4.0.63"> <!-- Sdk="MSBuild.SDK.System.Web/4.0.49" -->

  <Import Project="..\common.props" />

  <!-- If Visual Studio shows the following warning, copy the assembly binding redirects from the <runtime> element in
       file ./bin/Skarabee.CMS.SiteAdmin.dll.config to ./Web.config - Steven Volckaert, 10 August 2021.
       
       Warning MSB3276 Found conflicts between different versions of the same dependent assembly. Please set the 
       "AutoGenerateBindingRedirects" property to true in the project file. For more information, see 
       http://go.microsoft.com/fwlink/?LinkId=294190. -->

  <PropertyGroup>
    <EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
    <EnableDefaultNoneItems>false</EnableDefaultNoneItems>
    <RootNamespace>Skarabee.CMS.SiteAdmin</RootNamespace>
    <TargetFramework>net48</TargetFramework>
    <Version>1.0.0-alpha01</Version>
    <UserSecretsId>302f321d-8049-4733-85e7-6170981b1e94</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <Reference Include="System.ComponentModel.DataAnnotations" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.2" />
    <PackageReference Include="jQuery" Version="1.6.4" />
    <PackageReference Include="jQuery.UI.Combined" Version="1.8.11" />
    <PackageReference Include="jQuery.Validation" Version="1.9.0" />
    <PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.7" />
    <PackageReference Include="Microsoft.AspNet.Razor" Version="3.2.7" />
    <PackageReference Include="Microsoft.AspNet.SignalR.JS" Version="1.0.0" />
    <PackageReference Include="Microsoft.AspNet.SignalR.SystemWeb" Version="1.0.0" />
    <PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.7" />
    <PackageReference Include="Microsoft.AspNet.WebPages" Version="3.2.7" />
    <PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="3.6.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
    <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="5.0.8" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="5.0.0" />
    <PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0" />
    <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
    <PackageReference Include="NLog" Version="4.7.9" />
    <PackageReference Include="NLog.Extensions.Hosting" Version="1.7.2" />
    <PackageReference Include="Skarabee.Extensions.Core" Version="1.2.0-alpha08" />
    <PackageReference Include="Skarabee.Extensions.Microsoft.AspNet" Version="1.1.0-rc06" />
    <PackageReference Include="Skarabee.Extensions.Newtonsoft.Json" Version="1.0.0" />
    <PackageReference Include="Skarabee.Extensions.System.Net.Http" Version="1.1.0-alpha03" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="SauceControl.InheritDoc" PrivateAssets="all" Version="1.3.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Skarabee.CMS.Facade\Skarabee.CMS.Facade.csproj" />
    <ProjectReference Include="..\Skarabee.CMS.Infrastructure\Skarabee.CMS.Infrastructure.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="App_Code\*.cshtml" />
    <Content Include="Content\**" />
    <Content Include="Scripts\**" />
    <Content Include="Views\**" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="appsettings.json" />
    <Content Include="engineConfiguration.config" />
    <Content Include="Global.asax" />
    <Content Include="NLog.config" />
    <Content Include="robots.txt" />
  </ItemGroup>

  <ItemGroup>
    <None Include="Properties\launchSettings.json" />
    <None Include="Web.Debug.config" DependentUpon="Web.config" />
    <None Include="Web.Release.config" DependentUpon="Web.config" />
  </ItemGroup>

</Project>

Projects don't work with dotnet CLI tooling

Hi,
Great job on putting these together. I have using SDK projects for our .NET 4.8 projects but had some issues with our MVC projects. With the help from the work you have done plus the long running thread on .NET project system site (dotnet/project-system#2670) I was able to get most of it going. One issue I did run into is while trying to implement MvcBuildViews support to run the dotnet tooling for use on our build server. While your projects do work in the Visual Studio they fail to work from dotnet cmd line tools.

dotnet build for instance results in:

C:\Users\xxx.nuget\packages\msbuild.sdk.systemweb\4.0.33\Sdk\Sdk.targets(16,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\5.0.201\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\5.0.201\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk. [c:\Users\xxx\Downloads\MSBuild.SDK.SystemWeb-main\MSBuild.SDK.SystemWeb-main\samples\ExampleEmptyWebApplication\ExampleEmptyWebApplication.csproj]

Build FAILED.

If I remove this property group:

<PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
  </PropertyGroup>
  <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
  <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" />
</Project>

The problem is resolved. Any ideas on how to get this working from the cmd line?

Auto added aspnetcore handler and "module"

Let me start by saying that this project is a godsent!
Thank you for your work and effort on this!

While upgrading asp.net mvc 5 project the following lines got added to the project, possibly by VS 2022's code, possibly by this SDK, i'm not certain, unfortunately.

image

After my project failing to start at all, and just crashing, i found the culprit were those 2 lines.

After removing them, my project just works!
And since i'm not sure if the 2 lines were added by this SDK or not, i'm posting here, and maybe it can be added to the docs, so others can save themselves some debugging time :)

VsCode's new C# DevKit fails to launch

Re: dotnet/project-system#2670 (comment)

Yes FWIW my project includes a Properties/launchSettings.json file & Visual Studio can launch the project just fine.

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:51867/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

But the new C# Dev Kit fails with the following.

image

I'm thinking I might be able to get this working with a VsCode task to manually start IISExpress & then a custom launch config to attach to the process. But it would obviously be nicer if it just worked out of the box like it does in Visual Studio.

Content items brought in by EnableWebFormsDefaultItems include (published) output under bin and obj

@CZEMacLeod Thanks for the great work on this project. I updated to this version and noticed an issue after performing a publish.

In my project I end up with "bin\Release\Publish" as the output folder, however if turn on EnableWebFormsDefaultItems, once I publish it see's that published folder as content. Then each publish adds more content upon itself and eventually errors.

I have worked around this in some of my other globs by adding Exclude="$(DefaultItemExcludes)".

I recommend changing from:

<Content Include="**\*.asax" />
<Content Include="**\*.ascx" />
<Content Include="**\*.ashx" />
<Content Include="**\*.asmx" />
<Content Include="**\*.aspx" />
<Content Include="**\*.master" />

to

<Content Include="**\*.asax" Exclude="$(DefaultItemExcludes)" />
<Content Include="**\*.ascx" Exclude="$(DefaultItemExcludes)" />
<Content Include="**\*.ashx" Exclude="$(DefaultItemExcludes)" />
<Content Include="**\*.asmx" Exclude="$(DefaultItemExcludes)" />
<Content Include="**\*.aspx" Exclude="$(DefaultItemExcludes)" />
<Content Include="**\*.master" Exclude="$(DefaultItemExcludes)" />

Originally posted by @mcnallys in #24 (comment)

MSBuild.SDK.SystemWeb.RazorLibrary does not support GeneratedBindingRedirectsAction feature

The MSBuild.SDK.SystemWeb.RazorLibrary SDK type only obeys OverwriteAppConfigWithBindingRedirects and does not have the enhanced functionality of MSBuild.SDK.SystemWeb and GeneratedBindingRedirectsAction which was added in #36 to address #34.

We should copy the base functions of MSBuild.SDK.SystemWeb.BindingRedirects.targets to the Razor SDK type.

In the case of an MVC based project, it is often required to have a separate web.config in the Views directory and any Area's Views directory.

In the Razor SDK this is handled with an item type of RazorAppConfigFiles and an XmlPeek / XmlPoke for each file in the target that updates the main web.config file.

Now that we have a common files mechanism, and the fact you may have such additional web.config files in the main 'head' application, it would make sense to make this a combined/common feature.

node_modules is not ignored

If you have a large project that is doing any kind of globbed includes and you have a large number of node_modules then the sdk project system will consume an inordinate amount of resources- often crashing with an out of memory error. It will also be extremely slow to do any project operations- adding a new file, etc.

Adding this solved the problem for me:

 <ItemGroup>
    <EmbeddedResource Remove="node_modules\**" />
    <Compile Remove="node_modules\**" />
    <Content Remove="node_modules\**" />
    <None Remove="node_modules\**" />
  </ItemGroup>

I think this should be included to avoid this pitfall.

.aspx.designer.cs are not updated on .aspx save

Hi, let me first tell you this project is awesome. I'm testing it on our rather complex solution and it seems to work as smooth as Visual Studio should just do. This is great!

I am however experiencing an issue with aspx pages (no MVC here, plain old Web Forms). To reproduce it, create a new project using the Empty C# template (sdk 4.0.47), then add a web form called Default.aspx , complete with its codebehind Default.aspx.cs and its designer file Default.aspx.designer.cs.

Add a new <asp:Label runat="server" id="myLabel"></asp:Label> control and save the .aspx file. The control member variable should be available in the .designer.cs now, but it's not. It seems like the file is never regenerated.

Do you have any idea why?

Environment-specific Web.config files do not end up in a deployment package

I'm using MSBuild.SDK.SystemWeb version 4.0.79 in one of our ASP.NET applications, where I have included some environment-specific Web.config files, which contain XDT transforms:

image

They are in the csproj file as follows:

image

I'm using an Azure DevOps pipeline to build and publish the project with MSBuild. The publish task is using the WebPublish MSBuild target:

image

For some reason, the files Web.Release.Development.config and Web.Release.Staging.config do not end up in the output directory of the WebPublish MSBuild target; so they also do not appear in the build artifact.

Does anyone have an idea why this is?

This is not urgent, as I've worked around this issue by renaming the files to *.config.xml.

Thanks for looking into this!

Add support for autogenerated binding redirects that are not source controlled

I've been using this SDK for a while now in a bunch of our legacy projects to great success, however there is one pain point which I wanted to document here in the form of a proposal.

We are leveraging GeneratedBindingRedirectsAction as Overwrite in our projects. Whenever packages are updated in our solution, we need to make sure to rebuild it fully so that binding redirects in the legacy projects are adjusted as needed, before we can commit the changes. On our solution, this is a tedious process as it takes several minutes to build the entire project. It is also error prone, since if we don't perform this step, it ends up generating pending changes for other developers later, which is not something we want of course.

For modern projects, this issue has been resolved as binding redirects are "magically" taken care of: they never show up and are always up-to-date without the developer needing to do anything extra. I'd like an experience similar to that with this SDK.

Would it be possible to generate the binding redirects in a way that keeps them "decoupled" from the main web.config in such a way that the file can be generated and linked at build time, but doesn't need to be merged into source control? This would allow us to update the packages and don't have to worry about manually refreshing the binding redirects with a local build right after. No matter where the project was built, it would generate the redirects (probably in a separate file) and link it with the original web.config, using, say, a configSource path.

Add handling for ManagePackageVersionsCentrally

It would be nice if your scripts are working with this
https://github.com/NuGet/Home/wiki/Centrally-managing-NuGet-package-versions

Maybe a condition on the property group (setting ManagePackageVersionsCentrally) here https://github.com/CZEMacLeod/MSBuild.SDK.SystemWeb/blob/main/src/MSBuild.SDK.SystemWeb/Sdk/MSBuild.SDK.SystemWeb.DefaultPackages.props

Maybe an additional check on line 12 https://github.com/CZEMacLeod/MSBuild.SDK.SystemWeb/blob/main/src/MSBuild.SDK.SystemWeb/Sdk/MSBuild.SDK.SystemWeb.DefaultPackages.targets is also required for setting ManagePackageVersionsCentrally....

IIS Express profile launchSettings.json does not add environment variables in the iisexpress.exe process

Our current Web app csproj is currently using the great (and thank you so much) MSBuild.SDK.SystemWeb/4.0.88 Sdk and when we launch the IIS Express profile (in debug or without debugging) from VS 2022, it does add the environment variables to the iisexpress.exe process, is this normal? Notice that it is working with a default ASP.NET Core Web App default project.

This is our launchSettings.json

  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:51867/",
      "sslPort": 44301
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": false,
      "environmentVariables": {  // This does not work
        "ASPNETCORE_ENVIRONMENT": "Development",
        "AAA": "BBB"
      }
    }
  }
}

ASPCONFIG Could not load file or assembly 'Microsoft.CSharp, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

This happens only on Release mode. I already referenced nuget Microsoft.CSharp 4.7.0.0

"C:\projects****.csproj" (default target) (1) ->
(MvcBuildViews target) ->
ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 'Microsoft.CSharp, Version=5.0.
0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system canno
t find the file specified.

Propose to improve binding redirects genenration

Hello,

The current solution with a target to replace web.config with the build config file is not so bad, but implies to version kind of "statics" binding redirects. Moreover, I guess they will remains even if your dependancy doesn't need a binding redirect anymore, or if you uninstall it...

I suggest something like that in SystemWeb targets :

  <Target Name="AfterBuild">
    <XmlPeek XmlInputPath="$(TargetDir)\$(AssemblyName).dll.config"
             Query="/configuration/runtime">
      <Output TaskParameter="Result" ItemName="GeneratedBindings" />
    </XmlPeek>
    <WriteLinesToFile
        File="$(TargetDir)\Web.bindings.config"
        Overwrite="true"
        Lines="&lt;?xml version=&quot;1.0&quot;?&gt;&lt;configuration&gt;;@(GeneratedBindings);&lt;/configuration&gt;" />
  </Target>

And in your personal Web.config you remove ALL the binding redirects and you replace them by :

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  [...]
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <linkedConfiguration href="file:./bin/Web.bindings.config"/>
  </assemblyBinding>
</configuration>

What do you think about it ?

.aspx and .asax files don't get published

I'm deploying as follows:

msbuild /t:Restore,Rebuild /p:DeployOnBuild=true /p:PublishProfile=Live.pubxml
/p:Password="(my password)" /p:Configuration=Live .\MyProject\MyProject.csproj

This does build a new DLL and upload that and its dependencies to the server. However, it does not replace any aspx files on the server.

I notice VS infers the build action for aspx as None, and I'm not seeing a reason at a glance, in my csproj. Some snippets:

<Project Sdk="MSBuild.SDK.SystemWeb/4.0.49">
  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <UseIISExpress>true</UseIISExpress>
    <IISExpressSSLPort>44304</IISExpressSSLPort>
    <IISExpressAnonymousAuthentication />
    <IISExpressWindowsAuthentication />
    <IISExpressUseClassicPipelineMode />
    <UseGlobalApplicationHostFile />
    <Use64BitIISExpress />
    <LangVersion>9.0</LangVersion>
    <AssemblyTitle>MyProject</AssemblyTitle>
  </PropertyGroup>
  <ItemGroup>
    [.. a few package references]
  </ItemGroup>
  <ItemGroup>
    [.. a few linked files to add to compilation]
  </ItemGroup>
  <ItemGroup>
    <PackageReference Update="Microsoft.Net.Compilers.Toolset" Version="3.11.0" />
  </ItemGroup>
</Project>

I'm guessing asmx and ascx files would be affected as well.

So I think the default item includes should have:

  <ItemGroup>
    <Content Include="*.asax" />
    <Content Include="*.ascx" />
    <Content Include="*.asmx" />
    <Content Include="*.aspx" />
  </ItemGroup>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.