Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publishing a web api (net 9) is not correct #45196

Open
1 task done
drma-tech opened this issue Nov 26, 2024 · 3 comments
Open
1 task done

publishing a web api (net 9) is not correct #45196

drma-tech opened this issue Nov 26, 2024 · 3 comments
Labels
Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch Area-WebSDK untriaged Request triage from a team member

Comments

@drma-tech
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

when publishing an api to run on IIS, this file is generated

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
        </handlers>
    </system.webServer>
</configuration>

Expected Behavior

but it should be this one

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath=".\api.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: 13748f01-6805-4d10-9338-b3e33e8b1973-->

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

9

Anything else?

No response

@BrennanConroy BrennanConroy transferred this issue from dotnet/aspnetcore Nov 27, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Nov 27, 2024
@Forgind
Copy link
Member

Forgind commented Dec 19, 2024

@drma-tech How are you creating that (web.config?) file? It looks like a rudimentary form of what you want, so I'm wondering if it's expected that you start with that and modify it as necessary to arrive at something more similar to what you provided.

@drma-tech
Copy link
Author

I don't even know anymore. It generated this way right after the first official version. And it stopped generating definitively when the first Visual Studio fix came out.

@Forgind Forgind added Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch and removed Area-NetSDK labels Dec 24, 2024
@Forgind
Copy link
Member

Forgind commented Dec 24, 2024

Having looked around for a while, I believe that the logic that is intended to control this mostly lives here:
https://github.com/dotnet/sdk/blob/9098fdd20c35bf5e87f5f827248fd2989d612e1b/src/WebSdk/Publish/Tasks/Tasks/TransformWebConfig.cs

It appears that that part takes a web.config and adds the parts that were successfully added. It does not, however, include the aspNetCore element or the location element. There's a template here that adds the location part but not the aspNetCore element; since it appears that TransformWebConfig is executing (hence the handler) but that location element isn't added, that suggests that projectWebConfigPath existed.

I don't know how exactly that's added, but I think it's added through Microsoft.NET.Sdk.Publish.TransformFiles.targets via the web sdk:

<Import Project="$(_TransformTargetsDir)Microsoft.NET.Sdk.Publish.TransformFiles.targets" Condition="Exists('$(_TransformTargetsDir)Microsoft.NET.Sdk.Publish.TransformFiles.targets')"/>

That suggests that at some point, if you specify Sdk="Microsoft.NET.Sdk.Web" then build, it should find a web.config for you and modify it to have those elements...except your base version doesn't have the right elements?

I suspect that there may be an extra file near your project file that's causing trouble, but I've gotten pretty far away from things I'm confident of. Hopefully someone who knows more about the web sdk can chime in 🙂

@Forgind Forgind removed their assignment Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch Area-WebSDK untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

2 participants