Closed mitchcapper closed 2 months ago
Hello,
Sadly the solution had several problems even (like missing global section).
Sorry for the inconvenience. I think the master branch already contains the fixes for the mentioned problems.
I had some other problems in my life, again, while completing a planned release in March (voiced here ~ https://mastodon.social/@github3F/111975646026491387)
Now I'll try to finish 2.7 this April:
This is already on dev/2.7 branch with updated tests ! You can also test the latest stable 1abff30 before merge (I didn't open it as PR since in fact I have mostly private reports and local tasks)
ah yes, an easier way to create from scratch (empty map) is planned to review also together with 2.7, I think <_<
@mitchcapper, Is there a reason for trying to remove a Private from added Reference ?
I have checked your code and all the mentioned bugs seem to have been fixed in the upcoming version 2.7. This or next week, I think, should be released together with the new features through new ISlnWhData and IProjectsToucher implementations that will help to create .sln + project files from scratch, for example (2.7+):
ConfigSln[] slnConf = [new("Debug", "x64")];
ProjectItem[] projects = [new ProjectItem(ProjectType.CsSdk, @$"{projName}\src.csproj", slnDir: baseDir)];
IConfPlatformPrj[] prjConfs = [new ConfigPrj("Debug", "x64", projects[0].pGuid, build: true, slnConf[0])];
LhDataHelper hdata = new();
hdata.SetHeader(SlnHeader.MakeDefault())
.SetProjects(projects)
.SetProjectConfigs(prjConfs)
.SetSolutionConfigs(slnConf);
using(SlnWriter w = new(solutionFile, hdata))
{
w.Options = SlnWriterOptions.CreateProjectsIfNotExist;
w.Write();
}
using Sln sln = new(solutionFile, SlnItems.EnvWithMinimalProjects);
IXProject xp = sln.Result.Env.Projects.First();
xp.SetProperties(new Dictionary<string, string>()
{
{ "OutputType", "EXE" },
{ "TargetFramework", "net8.0" },
{ "Platforms", "x64" }
});
xp.Save();
the standard (2.x) way is also available, of course, for code from above it can be like:
Dictionary<Type, HandlerValue> whandlers = new()
{
[typeof(LVisualStudioVersion)] = new(new WVisualStudioVersion(SlnHeader.MakeDefault())),
[typeof(LProject)] = new(new WProject(projects)),
[typeof(LProjectConfigurationPlatforms)] = new(new WProjectConfigurationPlatforms(prjConfs)),
[typeof(LSolutionConfigurationPlatforms)] = new(new WSolutionConfigurationPlatforms(slnConf)),
};
using SlnWriter w = new(solutionFile, whandlers));
I'll edit my example above if anything changes before release.
Note also,
.Replace("TestProj|", "Debug|x64")
This is not a bug. You have incorrect initialization or incorrectly selected ctor (n. formatted instead of configuration + platform)
Is there a reason for trying to remove a Private from added Reference ?
Create a cleaner output. Wanted to generate the same thing as if one was to manually do it in VS essentially. That way VS also decides in terms of local copy or not.
.Replace("TestProj|", "Debug|x64") This is not a bug. You have incorrect initialization or incorrectly selected ctor (n. formatted instead of configuration + platform)
Thanks, 100% could be. I was unclear on the right combo of items to get it to be happy, it seemed like a ConfigSln would work there so took it out of the platformData.
New 2.7 style looks great and straightforward!
Create a cleaner output. Wanted to generate the same thing as if one was to manually do it in VS essentially. That way VS also decides in terms of local copy or not.
I added new method signatures through AddReferenceOptions enum that will help to control everything for Reference nodes. The old AddReference() (without AddReferenceOptions) has been marked as obsolete and scheduled to be removed in future versions.
For 2.7 you will be able use HidePrivate flag or some predefined option ~
Default = HideEmbedInteropTypes | HideSpecificVersion,
DefaultResolve = Default
| ResolveAssemblyName
| OmitArchitecture
| OmitCultureNeutral
| OmitPublicKeyTokenNull,
Mini = Default | HidePrivate,
MiniResolve = Mini | DefaultResolve | OmitCulture,
...
New 2.7 style looks great and straightforward!
MvsSln was based on a pluggable handlers at runtime and map to control everything (ideally).
2.7+ continues this path with new trivial wrappers that prepare data and handlers. This, unfortunately, only applies to the default set at this time, but... maybe 2.8 (well, my priority is to continue 3.0 with IeXod support and completely change IXProject ... someday)
Wanted to try and create a basic project/solution but ran into a good bit of difficulty.
Below is the code I tried, I had to fallback to MS to generate the project itself and then still had problems.
While there is no example of creating a project like this there is an example of creating an issue from scratch here. Sadly the solution had several problems even (like missing global section).
Here is what 'worked' but required various manual fixes (including commented out versions of what didn't work). Not sure if there is a better way: