/// <summary> /// Set up debug configuration in user file /// </summary> /// <param name="conf"></param> public static void SetupProjectOptions(this Project.Configuration conf) { conf.CsprojUserFile = new Project.Configuration.CsprojUserFileSettings(); conf.CsprojUserFile.StartAction = Project.Configuration.CsprojUserFileSettings.StartActionSetting.Program; string quote = Util.IsRunningInMono() ? @"\""" : @""""; // When running in Mono, we must escape " conf.CsprojUserFile.StartArguments = $@"/sources(@{quote}{string.Join(";", MainSources)}{quote})"; conf.CsprojUserFile.StartProgram = s_sharpmakeApplicationExePath; }
public virtual string GetSharpmakeExecutableFullPath() { string sharpmakeApplicationExePath = Process.GetCurrentProcess().MainModule.FileName; if (Util.IsRunningInMono()) { // When running within Mono, sharpmakeApplicationExePath will at this point wrongly refer to the // mono (or mono-sgen) executable. Fix it so that it points to Sharpmake.Application.exe. sharpmakeApplicationExePath = $"{AppDomain.CurrentDomain.BaseDirectory}{AppDomain.CurrentDomain.FriendlyName}"; } return(sharpmakeApplicationExePath); }
/// <summary> /// Add references to Sharpmake to given configuration. /// </summary> /// <param name="conf"></param> public static void AddSharpmakePackage(Project.Configuration conf) { if (s_sharpmakePackageName == null || s_sharpmakePackageVersion == null) { Assembly sharpmakeAssembly = Assembly.GetExecutingAssembly(); string assemblyProductName = sharpmakeAssembly.GetName().Name; string assemblyProductVersion = FileVersionInfo.GetVersionInfo(sharpmakeAssembly.Location).ProductVersion; var match = s_assemblyVersionRegex.Match(assemblyProductVersion); if (match == null || match.Groups.Count < 3) { throw new AssemblyVersionException($"Sharpmake assembly version '{assemblyProductVersion}' is not valid.\nFormat should be '1.2.3.4 [(variationName)]'."); } s_sharpmakePackageVersion = match.Groups[1].Value; string assemblyProductVariation = match.Groups[2].Value; s_sharpmakePackageName = $"{assemblyProductName}"; if (!string.IsNullOrWhiteSpace(assemblyProductVariation)) { s_sharpmakePackageName += $"-{assemblyProductVariation}"; } if (assemblyProductVariation == "LocalBuild") { // debug solution generated from local build s_useLocalSharpmake = true; s_sharpmakeDllPath = sharpmakeAssembly.Location; s_sharpmakeGeneratorDllPath = Assembly.Load("Sharpmake.Generators")?.Location; } s_sharpmakeApplicationExePath = Process.GetCurrentProcess().MainModule.FileName; if (Util.IsRunningInMono()) { // When running within Mono, s_sharpmakeApplicationExePath will at this point wrongly refer to the // mono (or mono-sgen) executable. Fix it so that it points to Sharpmake.Application.exe. s_sharpmakeApplicationExePath = $"{AppDomain.CurrentDomain.BaseDirectory}{AppDomain.CurrentDomain.FriendlyName}"; } } conf.ReferencesByPath.Add(Assembler.DefaultReferences); if (s_useLocalSharpmake) { conf.ReferencesByPath.Add(s_sharpmakeDllPath); conf.ReferencesByPath.Add(s_sharpmakeGeneratorDllPath); } else { conf.ReferencesByNuGetPackage.Add(s_sharpmakePackageName, s_sharpmakePackageVersion); } }
/// <summary> /// Set up debug configuration in user file /// </summary> /// <param name="conf"></param> /// <param name="startArguments"></param> public static void SetupProjectOptions(this Project.Configuration conf, string startArguments) { string sharpmakeApplicationExePath = Process.GetCurrentProcess().MainModule.FileName; if (Util.IsRunningInMono()) { // When running within Mono, sharpmakeApplicationExePath will at this point wrongly refer to the // mono (or mono-sgen) executable. Fix it so that it points to Sharpmake.Application.exe. sharpmakeApplicationExePath = $"{AppDomain.CurrentDomain.BaseDirectory}{AppDomain.CurrentDomain.FriendlyName}"; } conf.CsprojUserFile = new Project.Configuration.CsprojUserFileSettings(); conf.CsprojUserFile.StartAction = Project.Configuration.CsprojUserFileSettings.StartActionSetting.Program; string quote = Util.IsRunningInMono() ? @"\""" : @""""; // When running in Mono, we must escape " conf.CsprojUserFile.StartArguments = $@"/sources(@{quote}{string.Join(";", MainSources)}{quote}) {startArguments}"; conf.CsprojUserFile.StartProgram = sharpmakeApplicationExePath; }