C
C#2y ago
Indeed

VSCode working with SharedProjects [Answered]

VSCode seems to have problems with adding files to .projitems when working with SharedProjects. Are there any work around for this? For example using Wild Cards? My current .projitems
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>8EA92217-56DD-4A15-ADCF-9535B7972EEA</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>SharedProject</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)Models" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Localization\SharedResource.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Localization\SharedResource.en-US.resx" />
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>8EA92217-56DD-4A15-ADCF-9535B7972EEA</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>SharedProject</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)Models" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Localization\SharedResource.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Localization\SharedResource.en-US.resx" />
</ItemGroup>
</Project>
6 Replies
333fred
333fred2y ago
I would generally not advise using shared projects, for reasons like "they're not well supported by many tools and the file format is terrible" And vscode doesn't add things to project files at all. You need to do it by hand
Indeed
Indeed2y ago
I seem to have found a workaround in this github issue https://github.com/dotnet/project-system/issues/6010#issuecomment-687881459
GitHub
Modernize Shared Projects: Use globs in projitems files, allow edit...
Visual Studio Version: 16.6 Expected Behavior: Newly created projitems files contain a single line. &lt;Compile Include=&quot;$(MSBuildThisFileDirectory)***$(DefaultLanguageSourceExtension...
Indeed
Indeed2y ago
However i have also .resx files there, do i need to put them in csproj? Oh, seems embeded resources dont work now Should i just go with class library?
333fred
333fred2y ago
Yes, you should go with a class library
Indeed
Indeed2y ago
Thank you! ❤️ !close
Accord
Accord2y ago
✅ This post has been marked as answered!