Closed MarkKharitonov closed 2 years ago
It looks like you're trying to use the .NET SDK for something that is fundamentally not a .NET project as it has no C# (or VB or F#) source files and replaces the default Build behavior entirely. That's likely to break all sorts of assumptions the .NET Project System has about the project and how it works.
In general the Project System does not surface every MSBuild item in the Solution Explorer--that would be a lot of items, many of them irrelevant and confusing as they are an internal detail of the SDK. The Project System knows what Content
items are and how they behave (or at least how they behave by default in the .NET SDK) and so they are surfaced in the Solution Explorer; TypeScriptCompile
and Stylus
items are not known to the Project System, so they aren't shown.
What is it you are trying to achieve that you can't with a typical ASP.NET Core project?
We have an old enterprise application. It used to have 50 Asp.Net projects, but not because these projects represented a web application each. No, they just implemented different aspects of one big web application. During the build, these "fake" web applications build the Typescript and Stylus files using ad-hoc targets that run before Build
and copy the products to the big web application. We have downgraded these "fake" web applications to normal C# projects, but the fact that they mix C# and Typescript is problematic for us. So, we want to separate them - C# aside, legacy front end code aside. I call it legacy, because at the same time the front end is being migrated to React micro frontends. But right now there is a ton of legacy front end code and it would take literally years to migrate it all (it took us about 10 years to get rid of the Silverlight completely).
So, I am trying to figure out what project format to use for the legacy front end code. Right now, the SDK style projects is the best option I can see. The project files are small and the build code is injected through Directory.Build.* files (of course, the real files are more sophisticated than in my repro). The command line build using msbuild works great. But the VS IDE experience is a problem.
I am open to suggestions, but I cannot change the paradigm where front end code from many different projects is copied to a single location during the build, which corresponds to the location of the big web application.
If I could "tell" VS to show the Scripts folder that would have been the easiest.
If I could "tell" VS to show the Scripts folder that would have been the easiest.
MSBuild projects produce many many items of different types. It does not show all these items in Solution Explorer. It only shows certain types.
TypeScriptCompile
items are not shown. If you want to see them in the tree, you'll have to add them as a different type. For example:
<ItemGroup>
<None Include="@(TypeScriptCompile)" />
</ItemGroup>
Actually, a simpler approach may be for you to use this instead:
<ItemGroup>
<AvailableItemName Include="TypeScriptCompile" />
</ItemGroup>
I haven't tested this though.
@drewnoakes - The last approach does work. Thank you very much.
@drewnoakes - would you like to answer on my SO question, so that I could credit you there?
@MarkKharitonov sure, thanks. Done. I wanted to test my first suggestion on your repro but it seems you deleted the repo. Did it not work for you?
Also, for what you're trying to do, this might be helpful: https://github.com/microsoft/MSBuildSdks/tree/main/src/NoTargets
The repo was somehow private. I changed it back to public. Sorry for that.
Visual Studio version Microsoft Visual Studio Enterprise 2022 (64-bit) Version 17.0.4
Description I have a very simple custom SDK style project here (https://github.com/MarkKharitonov/HiddenFolders):
My problem is that VS Solution Explorer does not show the
Scripts
folder:The build code is trivial, but it replaces the standard build targets of the SDK:
Directory.Build.props
Directory.Build.targets
.\Approvals\Approvals.csproj
Very simple.
Why does VS Solution Explorer not show the Scripts folder?
P.S.
Also posted here - https://stackoverflow.com/questions/71164341/why-visual-studio-hides-certain-folders-in-a-codeless-c-sharp-project